Mejorada la información de debug

This commit is contained in:
2022-08-30 20:35:53 +02:00
parent 8616c3e165
commit 38c41193ec
3 changed files with 142 additions and 112 deletions

View File

@@ -3,192 +3,192 @@
# box height # box height
5 5
# 32 espacio ( ) # 32 espacio ( )
5 3
# 33 ! # 33 !
5 1
# 34 " # 34 "
5 3
# 35 # # 35 #
5 3
# 36 $ # 36 $
5 3
# 37 % # 37 %
5 3
# 38 & # 38 &
5 3
# 39 ' # 39 '
5 1
# 40 ( # 40 (
5 2
# 41 ) # 41 )
5 2
# 42 * # 42 *
5 3
# 43 + # 43 +
5 3
# 44 , # 44 ,
5 1
# 45 - # 45 -
5 3
# 46 . # 46 .
5 1
# 47 / # 47 /
5 3
# 48 0 # 48 0
5 3
# 49 1 # 49 1
5 3
# 50 2 # 50 2
5 3
# 51 3 # 51 3
5 3
# 52 4 # 52 4
5 3
# 53 5 # 53 5
5 3
# 54 6 # 54 6
5 3
# 55 7 # 55 7
5 3
# 56 8 # 56 8
5 3
# 57 9 # 57 9
5 3
# 58 : # 58 :
5 1
# 59 ; # 59 ;
5 1
# 60 < # 60 <
5 3
# 61 = # 61 =
5 3
# 62 > # 62 >
5 3
# 63 ? # 63 ?
5 3
# 64 @ # 64 @
5 3
# 65 A # 65 A
5 3
# 66 B # 66 B
5 3
# 67 C # 67 C
5 3
# 68 D # 68 D
5 3
# 69 E # 69 E
5 3
# 70 F # 70 F
5 3
# 71 G # 71 G
5 3
# 72 H # 72 H
5 3
# 73 I # 73 I
5 3
# 74 J # 74 J
5 3
# 75 K # 75 K
5 3
# 76 L # 76 L
5 3
# 77 M # 77 M
5 3
# 78 N # 78 N
5 3
# 79 O # 79 O
5 3
# 80 P # 80 P
5 3
# 81 Q # 81 Q
5 3
# 82 R # 82 R
5 3
# 83 S # 83 S
5 3
# 84 T # 84 T
5 3
# 85 U # 85 U
5 3
# 86 V # 86 V
5 3
# 87 W # 87 W
5 3
# 88 X # 88 X
5 3
# 89 Y # 89 Y
5 3
# 90 Z # 90 Z
5 3
# 91 [ # 91 [
5 2
# 92 \ # 92 \
5 3
# 93 ] # 93 ]
5 2
# 94 ^ # 94 ^
5 3
# 95 _ # 95 _
5 3
# 96 ` # 96 `
5 2
# 97 a # 97 a
5 3
# 98 b # 98 b
5 3
# 99 c # 99 c
5 3
# 100 d # 100 d
5 3
# 101 e # 101 e
5 3
# 102 f # 102 f
5 3
# 103 g # 103 g
5 3
# 104 h # 104 h
5 3
# 105 i # 105 i
5 3
# 106 j # 106 j
5 3
# 107 k # 107 k
5 3
# 108 l # 108 l
5 3
# 109 m # 109 m
5 3
# 110 n # 110 n
5 3
# 111 o # 111 o
5 3
# 112 p # 112 p
5 3
# 113 q # 113 q
5 3
# 114 r # 114 r
5 3
# 115 s # 115 s
5 3
# 116 t # 116 t
5 3
# 117 u # 117 u
5 3
# 118 v # 118 v
5 3
# 119 w # 119 w
5 3
# 120 x # 120 x
5 3
# 121 y # 121 y
5 3
# 122 z # 122 z
5 3
# 123 { # 123 {
5 3
# 124 | # 124 |
5 3
# 125 } # 125 }
5 3
# 126 ~ # 126 ~
5 5

View File

@@ -20,6 +20,7 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input)
player = new Player(spawnPoint, asset->get("player01.png"), asset->get("player01.ani"), renderer, asset, input, room); player = new Player(spawnPoint, asset->get("player01.png"), asset->get("player01.ani"), renderer, asset, input, room);
eventHandler = new SDL_Event(); eventHandler = new SDL_Event();
text = new Text(asset->get("smb2.png"), asset->get("smb2.txt"), renderer); text = new Text(asset->get("smb2.png"), asset->get("smb2.txt"), renderer);
debugText = new Text(asset->get("debug.png"), asset->get("debug.txt"), renderer);
// Inicializa variables // Inicializa variables
ticks = 0; ticks = 0;
@@ -51,6 +52,9 @@ Game::~Game()
delete text; delete text;
text = nullptr; text = nullptr;
delete debugText;
debugText = nullptr;
} }
// Bucle para el juego // Bucle para el juego
@@ -151,27 +155,49 @@ void Game::render()
text->writeCentered(GAMECANVAS_CENTER_X, 16 * 8, room->getName()); text->writeCentered(GAMECANVAS_CENTER_X, 16 * 8, room->getName());
// Debug info // Debug info
if (debug) renderDebugInfo();
// Actualiza la pantalla
screen->blit();
}
// Pone la información de debug en pantalla
void Game::renderDebugInfo()
{ {
if (!debug)
{
return;
}
// Pinta la rejilla
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 64);
for (int i = 0; i < PLAY_AREA_BOTTOM; i += 8)
{ // Lineas horizontales
SDL_RenderDrawLine(renderer, 0, i, PLAY_AREA_RIGHT, i);
}
for (int i = 0; i < PLAY_AREA_RIGHT; i += 8)
{ // Lineas verticales
SDL_RenderDrawLine(renderer, i, 0, i, PLAY_AREA_BOTTOM - 1);
}
// Pinta el texto
std::string text; std::string text;
int line = (16 * 8) + 3;
text = "status: " + std::to_string(player->status); text = "status: " + std::to_string(player->status);
this->text->write(0, 17 * 8, text); debugText->write(0, line += 6, text);
text = "foot: " + std::to_string((int)player->getLeftFoot().y); text = "foot: " + std::to_string((int)player->getLeftFoot().y);
this->text->write(0, 18 * 8, text); debugText->write(0, line += 6, text);
const int a = (player->lastPosition.y + 16) / 8; const int a = (player->lastPosition.y + 16) / 8;
const int b = player->getLeftFoot().y / 8; const int b = player->getLeftFoot().y / 8;
text = "tile: " + std::to_string(a) + " - " + std::to_string(b); text = "tile: " + std::to_string(a) + " - " + std::to_string(b);
this->text->write(0, 19 * 8, text); debugText->write(0, line += 6, text);
const bool collision = checkPlayerAndEnemies(); const bool collision = checkPlayerAndEnemies();
text = "collision: " + std::to_string(collision); text = "collision: " + std::to_string(collision);
this->text->write(0, 20 * 8, text); debugText->write(0, line += 6, text);
}
// Actualiza la pantalla
screen->blit();
} }
// Cambia de habitación // Cambia de habitación

View File

@@ -30,6 +30,7 @@ private:
Asset *asset; // Objeto con la ruta a todos los ficheros de recursos Asset *asset; // Objeto con la ruta a todos los ficheros de recursos
Input *input; // Objeto pata gestionar la entrada Input *input; // Objeto pata gestionar la entrada
Text *text; // Objeto para los textos del juego Text *text; // Objeto para los textos del juego
Text *debugText; // Objeto para los textos de debug del juego
int ticks; // Contador de ticks para ajustar la velocidad del programa int ticks; // Contador de ticks para ajustar la velocidad del programa
int ticksSpeed; // Velocidad a la que se repiten los bucles del programa int ticksSpeed; // Velocidad a la que se repiten los bucles del programa
section_t section; // Seccion actual dentro del juego section_t section; // Seccion actual dentro del juego
@@ -43,6 +44,9 @@ private:
// Pinta los objetos en pantalla // Pinta los objetos en pantalla
void render(); void render();
// Pone la información de debug en pantalla
void renderDebugInfo();
// Cambia de habitación // Cambia de habitación
bool changeRoom(std::string file); bool changeRoom(std::string file);