From 6059a3b894732c82aed5bba988070f780a4631cd Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sun, 10 Jul 2022 21:36:48 +0200 Subject: [PATCH] Arco de salto mejorado --- data/room/02.room | 2 +- source/game.cpp | 4 ++++ source/player.h | 4 ++-- source/room.cpp | 6 ++++-- todo.txt | 2 ++ 5 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 todo.txt diff --git a/data/room/02.room b/data/room/02.room index 37fed60..2d6486d 100644 --- a/data/room/02.room +++ b/data/room/02.room @@ -6,7 +6,7 @@ room_up=0 room_down=0 room_left=01.room room_right=0 -tilemap=43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,43,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,43,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,43,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,43,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,43,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,43,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,43,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,43,43,43,43,43,0,0,0,0,0,0,0,0,0,43,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,43,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,43,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,43,43,0,0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,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,43,0,0,0,0,0,0,0,83,83,83,83,83,83,0,0,0,0,0,0,3,0,0,0,0,83,83,0,0,0,0,0,0,0,0,0,0,0,83,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,43,43,43,43,43,43,43,43,43,43,43,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63 enemy=1,0,0,0,1 enemy=2,10,0,0,1 item=1,10,10 \ No newline at end of file diff --git a/source/game.cpp b/source/game.cpp index 7ca19aa..3d76978 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -213,6 +213,10 @@ void Game::checkPlayerOnFloor() { // Comprueba si tiene suelo bajo los pies solo cuando no hay velocidad de subida // y solo cuando el pie este encima de un bloque, es decir, en multiplos de 8 + + // *** HAY UN POSIBLE PROBLEMA y es que caiga muy rapido y viaje a mas de un pixel de velocidad, + // con lo que se saltaria la comprobación + if ((mPlayer->getVelY() >= 0) && ((int)mPlayer->getLeftFoot().y % 8 == 0)) { // Comprueba ambos pies bool test = false; diff --git a/source/player.h b/source/player.h index a8725f5..0714d74 100644 --- a/source/player.h +++ b/source/player.h @@ -16,8 +16,8 @@ #define STATUS_JUMPING 1 #define STATUS_FALLING 2 -#define GRAVITY 0.02f -#define MAX_VY 0.9f +#define GRAVITY 0.035f +#define MAX_VY 1.2f // Clase Player class Player diff --git a/source/room.cpp b/source/room.cpp index 576ebce..92c5d88 100644 --- a/source/room.cpp +++ b/source/room.cpp @@ -316,12 +316,14 @@ int Room::getTile(SDL_Point point) if (pos < 512) { - if (tilemap[pos] == 41) + // Los tiles entre el 1 y el 80 son solidos + if ((tilemap[pos] > 0) && (tilemap[pos] < 81)) { return TILE_SOLID; } - if (tilemap[pos] == 81) + // Los tiles mayores de 80 son atravesables + if (tilemap[pos] > 80) { return TILE_TRAVESSABLE; } diff --git a/todo.txt b/todo.txt new file mode 100644 index 0000000..d4b542b --- /dev/null +++ b/todo.txt @@ -0,0 +1,2 @@ +[ ] Hacer que deje de poder moverse tras el salto al alcanzar la misma posicion en altura que tenia cuando saltó +[ ] Leer los mapas directamente del archivo tmx \ No newline at end of file