dungeonanddeamon/DungeonAndDeamonScript/DungeonAndDemaonScript/GestionPlayer.h
2020-05-03 15:35:51 +02:00

96 lines
1.7 KiB
C++

#pragma once
#include <CircleShape2D.hpp>
#include <CollisionShape2D.hpp>
#include <Sprite.hpp>
#include <AnimatedSprite.hpp>
#include "Player.h"
using namespace godot;
class GestionPlayer : public KinematicBody2D
{
public:
AnimatedSprite* sprite_player_ptr;
Ref<Resource> texture_player_ptr;
private:
GODOT_CLASS(GestionPlayer, KinematicBody2D)
public:
GestionPlayer();
void static _register_methods();
void _physics_process(float delta);
void _process(float delta);
void _init();
void _ready();
void createPlayer();
void setupPlayer();
public:
Player p;
public:
void setPosition(float x, float y);
private:
void traitementInput();
void PlayerLogic_AutoReset();
void PlayerLogic(float dt);
void PlayerLogic_OnGround(float dt);
void PlayerLogic_Jump(float dt);
void PlayerLogic_FreeFall(float dt);
public:
const float speed = 100.f;
float pv = 100;
const float GamePlayMultiplicator = 100.0f;
const float gravity = 9.8f * GamePlayMultiplicator;
const float power_jump = -5.0f * GamePlayMultiplicator;
bool on_ground = false;
bool on_roof = false;
bool on_left_wall = false;
bool on_right_wall = false;
class S_PlayerState
{
public:
union
{
struct
{
unsigned int right : 1;
unsigned int left : 1;
unsigned int jump : 1;
unsigned int dash : 1;
unsigned int idle : 1;
unsigned int attack : 1;
unsigned int bigattack : 1;
unsigned int block : 1;
unsigned int freefall : 1;
unsigned int isInBlockingAnimation : 1;
};
unsigned int AllFlags; // to reset all bits at once
} Flags;
void Reset()
{
Flags.AllFlags = 0;
}
S_PlayerState() { Reset(); }
} playerState;
private:
Vector2 velocity;
Vector2 FLOOR;
};