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
5
# 32 espacio ( )
5
3
# 33 !
5
1
# 34 "
5
3
# 35 #
5
3
# 36 $
5
3
# 37 %
5
3
# 38 &
5
3
# 39 '
5
1
# 40 (
5
2
# 41 )
5
2
# 42 *
5
3
# 43 +
5
3
# 44 ,
5
1
# 45 -
5
3
# 46 .
5
1
# 47 /
5
3
# 48 0
5
3
# 49 1
5
3
# 50 2
5
3
# 51 3
5
3
# 52 4
5
3
# 53 5
5
3
# 54 6
5
3
# 55 7
5
3
# 56 8
5
3
# 57 9
5
3
# 58 :
5
1
# 59 ;
5
1
# 60 <
5
3
# 61 =
5
3
# 62 >
5
3
# 63 ?
5
3
# 64 @
5
3
# 65 A
5
3
# 66 B
5
3
# 67 C
5
3
# 68 D
5
3
# 69 E
5
3
# 70 F
5
3
# 71 G
5
3
# 72 H
5
3
# 73 I
5
3
# 74 J
5
3
# 75 K
5
3
# 76 L
5
3
# 77 M
5
3
# 78 N
5
3
# 79 O
5
3
# 80 P
5
3
# 81 Q
5
3
# 82 R
5
3
# 83 S
5
3
# 84 T
5
3
# 85 U
5
3
# 86 V
5
3
# 87 W
5
3
# 88 X
5
3
# 89 Y
5
3
# 90 Z
5
3
# 91 [
5
2
# 92 \
5
3
# 93 ]
5
2
# 94 ^
5
3
# 95 _
5
3
# 96 `
5
2
# 97 a
5
3
# 98 b
5
3
# 99 c
5
3
# 100 d
5
3
# 101 e
5
3
# 102 f
5
3
# 103 g
5
3
# 104 h
5
3
# 105 i
5
3
# 106 j
5
3
# 107 k
5
3
# 108 l
5
3
# 109 m
5
3
# 110 n
5
3
# 111 o
5
3
# 112 p
5
3
# 113 q
5
3
# 114 r
5
3
# 115 s
5
3
# 116 t
5
3
# 117 u
5
3
# 118 v
5
3
# 119 w
5
3
# 120 x
5
3
# 121 y
5
3
# 122 z
5
3
# 123 {
5
3
# 124 |
5
3
# 125 }
5
3
# 126 ~
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);
eventHandler = new SDL_Event();
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
ticks = 0;
@@ -51,6 +52,9 @@ Game::~Game()
delete text;
text = nullptr;
delete debugText;
debugText = nullptr;
}
// Bucle para el juego
@@ -151,27 +155,49 @@ void Game::render()
text->writeCentered(GAMECANVAS_CENTER_X, 16 * 8, room->getName());
// 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;
int line = (16 * 8) + 3;
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);
this->text->write(0, 18 * 8, text);
debugText->write(0, line += 6, text);
const int a = (player->lastPosition.y + 16) / 8;
const int b = player->getLeftFoot().y / 8;
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();
text = "collision: " + std::to_string(collision);
this->text->write(0, 20 * 8, text);
}
// Actualiza la pantalla
screen->blit();
debugText->write(0, line += 6, text);
}
// Cambia de habitación

View File

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