Añadido input al scoreboard

This commit is contained in:
2022-09-23 20:43:31 +02:00
parent 48f84d28bd
commit 4cf09d1535
9 changed files with 62 additions and 27 deletions

View File

@@ -1,13 +1,14 @@
#include "player.h"
// Constructor
Player::Player(SDL_Renderer *renderer, Asset *asset, Input *input, Map *map, Debug *debug)
Player::Player(SDL_Renderer *renderer, Asset *asset, Input *input, Map *map, Debug *debug, int *diamonds)
{
this->asset = asset;
this->renderer = renderer;
this->input = input;
this->map = map;
this->debug = debug;
this->diamonds = diamonds;
sound_jump = JA_LoadSound(asset->get("sound_player_jump.wav").c_str());
sound_death = JA_LoadSound(asset->get("sound_player_death.wav").c_str());
@@ -34,13 +35,13 @@ Player::Player(SDL_Renderer *renderer, Asset *asset, Input *input, Map *map, Deb
maxVY = 4.0f;
state = s_standing;
living = l_alive;
jumpPressed = false;
key.insert(key.end(), {0, 0, 0, 0, 0, 0});
const SDL_Point p = {0, 0};
collider.insert(collider.end(), {p, p, p, p, p, p, p, p, p, p, p, p});
underFeet.insert(underFeet.end(), {p, p, p});
hookedOnMovingPlatform = -1;
diamonds = 0;
colliderBox = getRect();
}
@@ -75,7 +76,6 @@ void Player::update()
debug->add("state " + std::to_string(state));
debug->add(map->getName() + " (" + map->getRoomFileName(b_top) + ", " + map->getRoomFileName(b_right) + ", " + map->getRoomFileName(b_bottom) + ", " + map->getRoomFileName(b_left) + ")");
debug->add("hookedOn = " + std::to_string(hookedOnMovingPlatform));
debug->add("DIAMONDS = " + std::to_string(diamonds));
}
// Dibuja el objeto
@@ -424,19 +424,19 @@ bool Player::isOnScreenBorder()
border = b_left;
return true;
}
else if (x > map->getPlayArea(b_right) - w)
{
border = b_right;
return true;
}
else if (y < map->getPlayArea(b_top))
{
border = b_top;
return true;
}
else if (y > map->getPlayArea(b_bottom) - h)
{
border = b_bottom;
@@ -495,7 +495,7 @@ int Player::checkActors()
if (name == a_diamond)
{
diamonds++;
*diamonds = *diamonds + 1;
JA_PlaySound(sound_coin);
map->getItem(index);
map->deleteActor(index);
@@ -520,4 +520,9 @@ SDL_Rect Player::getRect()
SDL_Rect &Player::getCollider()
{
return colliderBox;
}
// Comprueba los estados de vida
void Player::checkLivingState()
{
}