FIx: El jugador no se moria al caer de alto si se mantenia la tecla de slto pulsada

This commit is contained in:
2022-11-19 09:02:35 +01:00
parent d003b51de4
commit e90c61a416
6 changed files with 29 additions and 11 deletions

View File

@@ -1,6 +1,7 @@
#include "notify.h"
#include <string>
#include <stdio.h>
#include <iostream>
// Constructor
Notify::Notify(SDL_Renderer *renderer, std::string bitmapFile, std::string textFile)
@@ -36,6 +37,8 @@ void Notify::render()
{
notifications.at(i).sprite->render();
}
text->write(8,8,"TEXTO DE PRUEBA");
}
// Actualiza el estado de las notificaiones
@@ -114,7 +117,6 @@ void Notify::showText(std::string text)
const int despH = this->text->getCharacterSize() / 2;
const int despV = despH;
const int travelDist = height + despV;
// const int offset = (int)notifications.size() * (travelDist) + despV;
const int offset = (int)notifications.size() > 0 ? notifications.back().y + travelDist : despV;
// Crea la notificacion
@@ -142,6 +144,12 @@ void Notify::showText(std::string text)
// Añade la notificación a la lista
notifications.push_back(n);
//std::cout << "Notification " << notifications.size() << std::endl;
//std::cout << "width " << width << std::endl;
//std::cout << "height " << height << std::endl;
//std::cout << "offset " << offset << std::endl;
//std::cout << "desp " << despH << std::endl;
}
// Indica si hay notificaciones activas

View File

@@ -72,7 +72,7 @@ void Screen::blit()
SDL_RenderCopy(renderer, gameCanvas, nullptr, &dest);
// Dibuja las notificaciones
//renderNotifications();
renderNotifications();
// Muestra por pantalla el renderizador
SDL_RenderPresent(renderer);
@@ -361,7 +361,7 @@ void Screen::renderNotifications()
// return;
//}
SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight);
//SDL_RenderSetLogicalSize(renderer, windowWidth * options->windowSize, windowHeight * options->windowSize);
notify->render();
SDL_RenderSetLogicalSize(renderer, gameCanvasWidth, gameCanvasHeight);
//SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight);
}

View File

@@ -21,9 +21,9 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
this->options = options;
#ifdef DEBUG
currentRoom = "48.room";
const int x1 = 18;
const int y1 = 13;
currentRoom = "02.room";
const int x1 = 20;
const int y1 = 6;
spawnPoint = {x1 * 8, y1 * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL};
#endif

View File

@@ -823,6 +823,8 @@ void Player::setState(state_e value)
{
prevState = state;
state = value;
checkState();
}
// Comprueba si el jugador esta vivo

View File

@@ -14,7 +14,9 @@ Stats::Stats(std::string file)
// Destructor
Stats::~Stats()
{
#ifndef DEBUG
saveToFile();
#endif
list.clear();
}

View File

@@ -115,6 +115,12 @@ void Title::checkEventHandler()
switchPalette();
break;
#ifdef DEBUG
case SDL_SCANCODE_F6:
screen->showText("MAMA MIRA! SIN MANOS!");
break;
#endif
default:
break;
}