NppClone/src/player.h

64 lines
1.3 KiB
C
Raw Normal View History

2023-04-21 20:27:02 +02:00
#ifndef PLAYER_H
#define PLAYER_H
#include <azur/azur.h>
#include <azur/gint/render.h>
#include <cstdint>
#include <stdlib.h>
#include <num/num.h>
enum
{
STATIC = 0,
DRAFT = 1,
2023-04-21 20:27:02 +02:00
WALK = 2,
RUN = 3,
JUMP = 4,
FALL = 5,
};
enum
{
LEFT = -1,
CENTER = 0,
RIGHT = 1,
};
2023-04-21 20:27:02 +02:00
class Player
{
public:
Player( int16_t _x, int16_t _y );
~Player();
2023-04-22 12:50:03 +02:00
void Update( float dt );
2023-04-21 20:27:02 +02:00
void Render( );
2023-05-03 22:50:46 +02:00
void Left( float dt );
void Right( float dt );
void Nothing( float dt );
2023-04-21 20:27:02 +02:00
void Jump( float dt );
2023-05-03 22:50:46 +02:00
float currx, curry; // center position of the player
2023-04-22 12:50:03 +02:00
float nextx, nexty; // interim x and y position (to be tested to check if they can be actually achieved or not while moving)
2023-05-03 22:50:46 +02:00
2023-04-22 12:50:03 +02:00
float vx, vy; // speed of the player as per x and y coordinates
float ax, ay; // acceleration of the player as per x an y coordinates
2023-04-21 20:27:02 +02:00
2023-05-03 22:50:46 +02:00
uint16_t xscreen, yscreen;
uint8_t width, height; // width and height - for the hitbox
2023-04-21 20:27:02 +02:00
uint32_t last_tick;
bool playeronground = true;
2023-05-03 22:50:46 +02:00
float currentspeed = 0.0f;
2023-04-21 20:27:02 +02:00
int8_t direction = STATIC;
int8_t action = STATIC;
};
#endif