53 lines
1.5 KiB
C++
53 lines
1.5 KiB
C++
#pragma once
|
|
#include <SDL2/SDL.h>
|
|
#include "jail_audio.h"
|
|
#include "utils.h"
|
|
#include "input.h"
|
|
#include "animatedsprite.h"
|
|
#include "asset.h"
|
|
|
|
#ifndef PLAYER_H
|
|
#define PLAYER_H
|
|
|
|
// The player
|
|
class Player
|
|
{
|
|
private:
|
|
Asset *asset; // Objeto con la ruta a todos los ficheros de recursos
|
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
|
Input *input; // Objeto Input para gestionar las entradas
|
|
AnimatedSprite *sprite; // Objeto con los graficos, animaciones y posición del jugador
|
|
LTexture *texture; // Textura con los graficos del jugador
|
|
|
|
bool can_jump; // Si puede saltar
|
|
bool enabled; // Si está habilitado
|
|
bool standing; // Si esta de pie (o quieto?)
|
|
bool invulnerable; // Si es invulnerable
|
|
int coins; // Cantidad de monedas
|
|
int cooldown; // Tiempo de inhabilitación
|
|
int jumpforce; // Cantidad de pixels a desplazarse y velocidad que pilla al saltar
|
|
int lifes; // Cantidad de vidas
|
|
std::vector<bool> key; // Indica las llaves que posee el jugador
|
|
JA_Sound sound_coin; // Sonido al coger monedas
|
|
JA_Sound sound_death; // Sonido al morir
|
|
JA_Sound sound_jump; // Sonido al saltar
|
|
|
|
// Comprueba las entradas y modifica variables
|
|
void checkInput();
|
|
|
|
public:
|
|
// Constructor
|
|
Player(SDL_Renderer *renderer, Asset *asset, Input *input);
|
|
|
|
// Destructor
|
|
~Player();
|
|
|
|
// Actualiza todas las variables
|
|
void update();
|
|
|
|
// Dibuja el objeto
|
|
void render();
|
|
};
|
|
|
|
#endif
|