Files
aee-arcade/source/game/entities/player.hpp
T

34 lines
1.0 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
#include <SDL3/SDL.h>
#include "core/rendering/sprite/animated_sprite.hpp"
class Player : public AnimatedSprite {
public:
// Mapeig de tecles per al moviment del jugador. Cada jugador local en pot
// tenir unes diferents; així podem afegir-ne més sense tocar el codi del
// Player, només instanciant amb Controls distints.
struct Controls {
SDL_Scancode up;
SDL_Scancode down;
SDL_Scancode left;
SDL_Scancode right;
};
// Sprite 12×24 amb perspectiva falsa: la base real del jugador són els
// 12×12 inferiors. Per això el bounding horitzontal és l'amplada completa,
// però verticalment permetem que el cap (12px superiors) isca fora de la
// pantalla — s'hi fa clipping natural al render.
static constexpr int SPRITE_WIDTH = 12;
static constexpr int SPRITE_HEIGHT = 24;
static constexpr int COLLISION_HEIGHT = 12;
Player(float x, float y, const Controls& controls);
void update(float delta_time) override;
private:
Controls controls_;
};