debugging onfloor()
This commit is contained in:
BIN
media/sound/sound_drop_enemy.wav
Normal file → Executable file
BIN
media/sound/sound_drop_enemy.wav
Normal file → Executable file
Binary file not shown.
BIN
media/sound/sound_drop_splat.wav
Normal file → Executable file
BIN
media/sound/sound_drop_splat.wav
Normal file → Executable file
Binary file not shown.
BIN
media/sound/sound_menu_logo.wav
Normal file → Executable file
BIN
media/sound/sound_menu_logo.wav
Normal file → Executable file
Binary file not shown.
BIN
media/sound/sound_menu_start.wav
Normal file → Executable file
BIN
media/sound/sound_menu_start.wav
Normal file → Executable file
Binary file not shown.
BIN
media/sound/sound_player_coin.wav
Normal file → Executable file
BIN
media/sound/sound_player_coin.wav
Normal file → Executable file
Binary file not shown.
BIN
media/sound/sound_player_death.wav
Normal file → Executable file
BIN
media/sound/sound_player_death.wav
Normal file → Executable file
Binary file not shown.
BIN
media/sound/sound_player_jump.wav
Normal file → Executable file
BIN
media/sound/sound_player_jump.wav
Normal file → Executable file
Binary file not shown.
@@ -48,12 +48,12 @@ const Uint16 GAME_WINDOW_WIDTH = 320;
|
|||||||
const Uint16 GAME_WINDOW_HEIGHT = 234;
|
const Uint16 GAME_WINDOW_HEIGHT = 234;
|
||||||
|
|
||||||
const Uint8 TEST_ROOM = 118; // 161
|
const Uint8 TEST_ROOM = 118; // 161
|
||||||
const Uint8 STARTING_ROOM = 25;
|
const Uint8 STARTING_ROOM = 2;
|
||||||
const Uint8 STARTING_PLAYER_TILE_X = 5;
|
const Uint8 STARTING_PLAYER_TILE_X = 5;
|
||||||
const Uint8 STARTING_PLAYER_TILE_Y = 11;
|
const Uint8 STARTING_PLAYER_TILE_Y = 11;
|
||||||
const Uint8 ENEMY_HITBOX_REDUCTION = 4;
|
const Uint8 ENEMY_HITBOX_REDUCTION = 4;
|
||||||
const Uint8 COOLDOWN_TIME = 50;
|
const Uint8 COOLDOWN_TIME = 50;
|
||||||
const Uint8 GRAVITY = 1;
|
const Uint8 GRAVITY = 0;
|
||||||
const Uint8 MAX_SPEED_Y = 5;
|
const Uint8 MAX_SPEED_Y = 5;
|
||||||
const Uint8 BASE_SPEED = 1;
|
const Uint8 BASE_SPEED = 1;
|
||||||
const Uint8 MAX_SPEED = 8;
|
const Uint8 MAX_SPEED = 8;
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
JA_DeleteMusic(a); \
|
JA_DeleteMusic(a); \
|
||||||
a = nullptr
|
a = nullptr
|
||||||
|
|
||||||
|
Uint8 _GRAVITY = 0;
|
||||||
void allocatePointers()
|
void allocatePointers()
|
||||||
{
|
{
|
||||||
// Textures
|
// Textures
|
||||||
@@ -855,32 +856,32 @@ void EndPlayer()
|
|||||||
void IniHud()
|
void IniHud()
|
||||||
{
|
{
|
||||||
loadTextureFromFile(hud.sprite, FILE_HUD.c_str(), renderer);
|
loadTextureFromFile(hud.sprite, FILE_HUD.c_str(), renderer);
|
||||||
hud.src_rect.x = 0;
|
hud.src_rect.x = 0; // Origen de la textura para el marcador
|
||||||
hud.src_rect.y = 0;
|
hud.src_rect.y = 0;
|
||||||
hud.src_rect.w = 320;
|
hud.src_rect.w = 320;
|
||||||
hud.src_rect.h = 16;
|
hud.src_rect.h = 16;
|
||||||
|
|
||||||
hud.dst_rect.x = 0;
|
hud.dst_rect.x = 0; // Donde se pinta el marcador
|
||||||
hud.dst_rect.y = 224;
|
hud.dst_rect.y = 224;
|
||||||
hud.dst_rect.w = 320;
|
hud.dst_rect.w = 320;
|
||||||
hud.dst_rect.h = 16;
|
hud.dst_rect.h = 16;
|
||||||
|
|
||||||
hud.num_src_rect.x = 0;
|
hud.num_src_rect.x = 0; // Coordenada al primer numero pequeño
|
||||||
hud.num_src_rect.y = 16;
|
hud.num_src_rect.y = 16;
|
||||||
hud.num_src_rect.w = 5;
|
hud.num_src_rect.w = 5;
|
||||||
hud.num_src_rect.h = 5;
|
hud.num_src_rect.h = 5;
|
||||||
|
|
||||||
hud.num_dst_rect.x = 0;
|
hud.num_dst_rect.x = 0; // Donde se pinta el numero pequeño
|
||||||
hud.num_dst_rect.y = 16;
|
hud.num_dst_rect.y = 16;
|
||||||
hud.num_dst_rect.w = 5;
|
hud.num_dst_rect.w = 5;
|
||||||
hud.num_dst_rect.h = 5;
|
hud.num_dst_rect.h = 5;
|
||||||
|
|
||||||
hud.bignum_src_rect.x = 0;
|
hud.bignum_src_rect.x = 0; // Coordenada al primer numero grande
|
||||||
hud.bignum_src_rect.y = 21;
|
hud.bignum_src_rect.y = 21;
|
||||||
hud.bignum_src_rect.w = 7;
|
hud.bignum_src_rect.w = 7;
|
||||||
hud.bignum_src_rect.h = 7;
|
hud.bignum_src_rect.h = 7;
|
||||||
|
|
||||||
hud.bignum_dst_rect.x = 0;
|
hud.bignum_dst_rect.x = 0; // Donde se pinta el numero grande
|
||||||
hud.bignum_dst_rect.y = 21;
|
hud.bignum_dst_rect.y = 21;
|
||||||
hud.bignum_dst_rect.w = 7;
|
hud.bignum_dst_rect.w = 7;
|
||||||
hud.bignum_dst_rect.h = 7;
|
hud.bignum_dst_rect.h = 7;
|
||||||
@@ -948,25 +949,16 @@ void KillPlayer()
|
|||||||
|
|
||||||
bool OnFloor()
|
bool OnFloor()
|
||||||
{
|
{
|
||||||
Uint8 tile_on_right_foot;
|
Uint8 tile_under_left_foot = ReadMapTile((player.dst_rect.x + 3) / MAP_TILE_WIDTH, (player.dst_rect.y + player.dst_rect.h) / MAP_TILE_HEIGHT);
|
||||||
Uint8 tile_on_left_foot;
|
Uint8 tile_under_right_foot = ReadMapTile((player.dst_rect.x + player.dst_rect.w - 4) / MAP_TILE_WIDTH, (player.dst_rect.y + player.dst_rect.h) / MAP_TILE_HEIGHT);
|
||||||
Uint8 tile_under_right_foot;
|
|
||||||
Uint8 tile_under_left_foot;
|
|
||||||
|
|
||||||
bool i_am_above_platform;
|
bool i_am_above_platform = ((tile_under_left_foot = TILE_PLATFORM) || (tile_under_right_foot = TILE_PLATFORM));
|
||||||
bool i_am_above_travesable;
|
bool i_am_above_travesable = ((tile_under_left_foot = TILE_TRAVESABLE_PLATFORM) || (tile_under_right_foot = TILE_TRAVESABLE_PLATFORM));
|
||||||
bool i_am_on_background;
|
|
||||||
|
|
||||||
tile_under_left_foot = ReadMapTile((player.dst_rect.x + 3) / MAP_TILE_WIDTH, (player.dst_rect.y + player.dst_rect.h) / MAP_TILE_HEIGHT);
|
Uint8 tile_on_left_foot = ReadMapTile((player.dst_rect.x + 3) / MAP_TILE_WIDTH, (player.dst_rect.y + player.dst_rect.h - 1) / MAP_TILE_HEIGHT);
|
||||||
tile_under_right_foot = ReadMapTile((player.dst_rect.x + player.dst_rect.w - 4) / MAP_TILE_WIDTH, (player.dst_rect.y + player.dst_rect.h) / MAP_TILE_HEIGHT);
|
Uint8 tile_on_right_foot = ReadMapTile((player.dst_rect.x + player.dst_rect.w - 4) / MAP_TILE_WIDTH, (player.dst_rect.y + player.dst_rect.h - 1) / MAP_TILE_HEIGHT);
|
||||||
|
|
||||||
i_am_above_platform = ((tile_under_left_foot = TILE_PLATFORM) || (tile_under_right_foot = TILE_PLATFORM));
|
bool i_am_on_background = ((tile_on_left_foot = TILE_BACKGROUND) && (tile_on_right_foot = TILE_BACKGROUND));
|
||||||
i_am_above_travesable = ((tile_under_left_foot = TILE_TRAVESABLE_PLATFORM) || (tile_under_right_foot = TILE_TRAVESABLE_PLATFORM));
|
|
||||||
|
|
||||||
tile_on_left_foot = ReadMapTile((player.dst_rect.x + 3) / MAP_TILE_WIDTH, (player.dst_rect.y + player.dst_rect.h - 1) / MAP_TILE_HEIGHT);
|
|
||||||
tile_on_right_foot = ReadMapTile((player.dst_rect.x + player.dst_rect.w - 4) / MAP_TILE_WIDTH, (player.dst_rect.y + player.dst_rect.h - 1) / MAP_TILE_HEIGHT);
|
|
||||||
|
|
||||||
i_am_on_background = ((tile_on_left_foot = TILE_BACKGROUND) && (tile_on_right_foot = TILE_BACKGROUND));
|
|
||||||
|
|
||||||
if (((i_am_above_platform) || (i_am_above_travesable)) && (i_am_on_background))
|
if (((i_am_above_platform) || (i_am_above_travesable)) && (i_am_on_background))
|
||||||
return true;
|
return true;
|
||||||
@@ -1440,7 +1432,7 @@ void ApplyGravity()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Si no toca piso aleshores s'incrementa la velocitat vertical
|
// Si no toca piso aleshores s'incrementa la velocitat vertical
|
||||||
player.speed_y = player.speed_y + GRAVITY;
|
player.speed_y = player.speed_y + _GRAVITY;
|
||||||
|
|
||||||
// La velocitat no pot ser mai superior a la altura d'un tile del mapa, per a que no els atravesse
|
// La velocitat no pot ser mai superior a la altura d'un tile del mapa, per a que no els atravesse
|
||||||
//player.speed_y = std::max(std::min(player.speed_y, MAX_SPEED_Y), -(MAX_SPEED_Y));
|
//player.speed_y = std::max(std::min(player.speed_y, MAX_SPEED_Y), -(MAX_SPEED_Y));
|
||||||
@@ -1521,27 +1513,33 @@ void DrawHud()
|
|||||||
if (prog.debug)
|
if (prog.debug)
|
||||||
{
|
{
|
||||||
// Pinta el valor x,y del jugador
|
// Pinta el valor x,y del jugador
|
||||||
|
// Centena de X
|
||||||
hud.num_src_rect.x = (player.dst_rect.x / 100) * hud.num_src_rect.w;
|
hud.num_src_rect.x = (player.dst_rect.x / 100) * hud.num_src_rect.w;
|
||||||
hud.num_dst_rect.y = 1;
|
hud.num_dst_rect.y = 1;
|
||||||
hud.num_dst_rect.x = 1;
|
hud.num_dst_rect.x = 1;
|
||||||
DrawSprite(hud.sprite, hud.num_src_rect, hud.num_dst_rect);
|
DrawSprite(hud.sprite, hud.num_src_rect, hud.num_dst_rect);
|
||||||
|
|
||||||
|
// Decena de X
|
||||||
hud.num_src_rect.x = ((player.dst_rect.x % 100) / 10) * hud.num_src_rect.w;
|
hud.num_src_rect.x = ((player.dst_rect.x % 100) / 10) * hud.num_src_rect.w;
|
||||||
hud.num_dst_rect.x = 5;
|
hud.num_dst_rect.x = 5;
|
||||||
DrawSprite(hud.sprite, hud.num_src_rect, hud.num_dst_rect);
|
DrawSprite(hud.sprite, hud.num_src_rect, hud.num_dst_rect);
|
||||||
|
|
||||||
|
// Unidad de X
|
||||||
hud.num_src_rect.x = (player.dst_rect.x % 10) * hud.num_src_rect.w;
|
hud.num_src_rect.x = (player.dst_rect.x % 10) * hud.num_src_rect.w;
|
||||||
hud.num_dst_rect.x = 9;
|
hud.num_dst_rect.x = 9;
|
||||||
DrawSprite(hud.sprite, hud.num_src_rect, hud.num_dst_rect);
|
DrawSprite(hud.sprite, hud.num_src_rect, hud.num_dst_rect);
|
||||||
|
|
||||||
|
// Centena de Y
|
||||||
hud.num_src_rect.x = (player.dst_rect.y / 100) * hud.num_src_rect.w;
|
hud.num_src_rect.x = (player.dst_rect.y / 100) * hud.num_src_rect.w;
|
||||||
hud.num_dst_rect.x = 17;
|
hud.num_dst_rect.x = 17;
|
||||||
DrawSprite(hud.sprite, hud.num_src_rect, hud.num_dst_rect);
|
DrawSprite(hud.sprite, hud.num_src_rect, hud.num_dst_rect);
|
||||||
|
|
||||||
|
// Decena de Y
|
||||||
hud.num_src_rect.x = ((player.dst_rect.y % 100) / 10) * hud.num_src_rect.w;
|
hud.num_src_rect.x = ((player.dst_rect.y % 100) / 10) * hud.num_src_rect.w;
|
||||||
hud.num_dst_rect.x = 21;
|
hud.num_dst_rect.x = 21;
|
||||||
DrawSprite(hud.sprite, hud.num_src_rect, hud.num_dst_rect);
|
DrawSprite(hud.sprite, hud.num_src_rect, hud.num_dst_rect);
|
||||||
|
|
||||||
|
// Unidad de Y
|
||||||
hud.num_src_rect.x = (player.dst_rect.y % 10) * hud.num_src_rect.w;
|
hud.num_src_rect.x = (player.dst_rect.y % 10) * hud.num_src_rect.w;
|
||||||
hud.num_dst_rect.x = 25;
|
hud.num_dst_rect.x = 25;
|
||||||
DrawSprite(hud.sprite, hud.num_src_rect, hud.num_dst_rect);
|
DrawSprite(hud.sprite, hud.num_src_rect, hud.num_dst_rect);
|
||||||
@@ -1555,24 +1553,29 @@ void DrawHud()
|
|||||||
hud.num_dst_rect.x = 33;
|
hud.num_dst_rect.x = 33;
|
||||||
DrawSprite(hud.sprite, hud.num_src_rect, hud.num_dst_rect);
|
DrawSprite(hud.sprite, hud.num_src_rect, hud.num_dst_rect);
|
||||||
|
|
||||||
|
// tile_under_left_foot
|
||||||
hud.num_src_rect.x = (ReadMapTile((player.dst_rect.x + 3) / MAP_TILE_WIDTH, (player.dst_rect.y + player.dst_rect.h) / MAP_TILE_HEIGHT)) * hud.num_src_rect.w;
|
hud.num_src_rect.x = (ReadMapTile((player.dst_rect.x + 3) / MAP_TILE_WIDTH, (player.dst_rect.y + player.dst_rect.h) / MAP_TILE_HEIGHT)) * hud.num_src_rect.w;
|
||||||
hud.num_dst_rect.x = 37;
|
hud.num_dst_rect.x = 37;
|
||||||
DrawSprite(hud.sprite, hud.num_src_rect, hud.num_dst_rect);
|
DrawSprite(hud.sprite, hud.num_src_rect, hud.num_dst_rect);
|
||||||
|
|
||||||
|
//tile_under_right_foot
|
||||||
hud.num_src_rect.x = (ReadMapTile((player.dst_rect.x + player.dst_rect.w - 4) / MAP_TILE_WIDTH, (player.dst_rect.y + player.dst_rect.h) / MAP_TILE_HEIGHT)) * hud.num_src_rect.w;
|
hud.num_src_rect.x = (ReadMapTile((player.dst_rect.x + player.dst_rect.w - 4) / MAP_TILE_WIDTH, (player.dst_rect.y + player.dst_rect.h) / MAP_TILE_HEIGHT)) * hud.num_src_rect.w;
|
||||||
hud.num_dst_rect.x = 41;
|
hud.num_dst_rect.x = 41;
|
||||||
DrawSprite(hud.sprite, hud.num_src_rect, hud.num_dst_rect);
|
DrawSprite(hud.sprite, hud.num_src_rect, hud.num_dst_rect);
|
||||||
|
|
||||||
// Pinta el numero d'habitaci<EFBFBD>
|
// Pinta el numero de habitación
|
||||||
|
// Centena
|
||||||
hud.num_src_rect.x = (map.room / 100) * hud.num_src_rect.w;
|
hud.num_src_rect.x = (map.room / 100) * hud.num_src_rect.w;
|
||||||
hud.num_dst_rect.y = 1;
|
hud.num_dst_rect.y = 1;
|
||||||
hud.num_dst_rect.x = 49;
|
hud.num_dst_rect.x = 49;
|
||||||
DrawSprite(hud.sprite, hud.num_src_rect, hud.num_dst_rect);
|
DrawSprite(hud.sprite, hud.num_src_rect, hud.num_dst_rect);
|
||||||
|
|
||||||
|
// Decena
|
||||||
hud.num_src_rect.x = ((map.room % 100) / 10) * hud.num_src_rect.w;
|
hud.num_src_rect.x = ((map.room % 100) / 10) * hud.num_src_rect.w;
|
||||||
hud.num_dst_rect.x = 53;
|
hud.num_dst_rect.x = 53;
|
||||||
DrawSprite(hud.sprite, hud.num_src_rect, hud.num_dst_rect);
|
DrawSprite(hud.sprite, hud.num_src_rect, hud.num_dst_rect);
|
||||||
|
|
||||||
|
// Unidad
|
||||||
hud.num_src_rect.x = (map.room % 10) * hud.num_src_rect.w;
|
hud.num_src_rect.x = (map.room % 10) * hud.num_src_rect.w;
|
||||||
hud.num_dst_rect.x = 57;
|
hud.num_dst_rect.x = 57;
|
||||||
DrawSprite(hud.sprite, hud.num_src_rect, hud.num_dst_rect);
|
DrawSprite(hud.sprite, hud.num_src_rect, hud.num_dst_rect);
|
||||||
@@ -1799,7 +1802,7 @@ void IniProgram()
|
|||||||
event = new SDL_Event();
|
event = new SDL_Event();
|
||||||
|
|
||||||
prog.music_enabled = true;
|
prog.music_enabled = true;
|
||||||
prog.filter = true;
|
prog.filter = false;
|
||||||
SetProgSection(SECTION_MENU);
|
SetProgSection(SECTION_MENU);
|
||||||
prog.debug = true;
|
prog.debug = true;
|
||||||
|
|
||||||
@@ -1920,6 +1923,8 @@ int main(int argc, char *args[])
|
|||||||
|
|
||||||
case SDL_SCANCODE_G:
|
case SDL_SCANCODE_G:
|
||||||
player.lifes = 255;
|
player.lifes = 255;
|
||||||
|
_GRAVITY++;
|
||||||
|
_GRAVITY %= 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_SCANCODE_M:
|
case SDL_SCANCODE_M:
|
||||||
@@ -1935,6 +1940,14 @@ int main(int argc, char *args[])
|
|||||||
LoadRoom(TEST_ROOM);
|
LoadRoom(TEST_ROOM);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SDL_SCANCODE_Z:
|
||||||
|
player.dst_rect.y--;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDL_SCANCODE_X:
|
||||||
|
player.dst_rect.y++;
|
||||||
|
break;
|
||||||
|
|
||||||
case SDL_SCANCODE_F1:
|
case SDL_SCANCODE_F1:
|
||||||
prog.debug = !prog.debug;
|
prog.debug = !prog.debug;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user