You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
2.6 KiB

#include "debug.h"
#include "../game.h"
#include "uiContainer.h"
#include "string.h"
#include <stdio.h>
#include "../Input/inputHandler.h"
void DebugDraw(Game *game){
char strings[30][41]; // Platz für bis zu 30 Strings der Länge 40
int lineamount = 0; // sollte aktuell gehalten werden, wie viele Lines sind aktuell im Strings Array
int neededWidth = MeasureText("1234567890123456789012345", DEBUG_FONT_SIZE); // sollte an den längsten debug String angepasst werden, damit dieser noch reinpasst
// Hier die Debug Information in den Strings Array einfügen
// im Endeffekt einfach im Array an der Stelle lineamount++ die Elemente einfügen
sprintf(strings[lineamount++], "FPS: %d", GetFPS());
sprintf(strings[lineamount++], "Screen: %d", game->currentScreen);
sprintf(strings[lineamount++], "MouseScreenX: %d", GetMouseX());
sprintf(strings[lineamount++], "MouseScreenY: %d", GetMouseY());
sprintf(strings[lineamount++], "MouseWorldX: %d", (int)game->inputHandler->cursorWorldPos.x);
sprintf(strings[lineamount++], "MouseWorldY: %d", (int)game->inputHandler->cursorWorldPos.y);
sprintf(strings[lineamount++], "WorldTile: %d", (int)game->inputHandler->cursorWorldTile.x);
sprintf(strings[lineamount++], "WorldTile: %d", (int)game->inputHandler->cursorWorldTile.y);
sprintf(strings[lineamount++], "DEPTH: %d", (int)(game->inputHandler->cursorWorldPos.x + game->inputHandler->cursorWorldPos.y));
sprintf(strings[lineamount++], "Camera Zoom: %f", game->camera->zoom);
sprintf(strings[lineamount++], "Sprite Amount: %d", game->sprites->spriteAmount);
sprintf(strings[lineamount++], "Draw Tile ID: %d", game->inputHandler->drawTileId);
// Hier müssten wir eine bessere Lösung finden, das flackert weil pressed nur für einen Frame gilt. Eine ähnliche Funktion gibt es für CharDown leider nicht, müssten wir selbst programmieren. Ich habe es erstmal nicht auskommentiert. Kann man aber easy machen sollte es stören
int pressed = GetCharPressed();
while(pressed != 0){
sprintf(strings[lineamount++], "Ḱey Pressed: %c", pressed);
pressed = GetCharPressed();
}
// Drawed eine Box für die Debug Info
DrawRectangleLines(0, 0, neededWidth, lineamount * DEBUG_FONT_SIZE + 5, (Color){0, 0, 0, 255});
DrawRectangle(0, 0, neededWidth, lineamount * DEBUG_FONT_SIZE + 5, (Color){0, 0, 0, 150});
// Drawed den Inhalt des "strings" Arrays
int counter = 0;
while(counter < lineamount){
DrawText(strings[counter], 2, counter * DEBUG_FONT_SIZE + 2, DEBUG_FONT_SIZE, (Color){220, 25, 25, 255});
counter++;
}
}