mirror of
https://forge.univ-lyon1.fr/tplifap4/dungeonanddeamon.git
synced 2024-02-27 13:31:50 +01:00
deplacment basique joueur
This commit is contained in:
@ -84,27 +84,40 @@ void GestionPlayer::setupPlayer()
|
||||
void GestionPlayer::traitementInput()
|
||||
{
|
||||
p.velocity = Vector2(0, 0);
|
||||
FLOOR = Vector2(0, -1);
|
||||
|
||||
Input* i = Input::get_singleton();
|
||||
|
||||
if (i->is_action_pressed("ui_left"))
|
||||
gauche();
|
||||
else if (i->is_action_pressed("ui_right"))
|
||||
if (i->is_action_pressed("ui_right"))
|
||||
droit();
|
||||
else if (i->is_key_pressed(0x39))
|
||||
if (i->is_action_pressed("ui_select"))
|
||||
saut();
|
||||
|
||||
|
||||
|
||||
|
||||
if (is_on_floor()) {
|
||||
on_ground = true;
|
||||
p.velocity.y += 0;
|
||||
}
|
||||
else {
|
||||
on_ground = false;
|
||||
p.velocity.y += gravity;
|
||||
}
|
||||
}
|
||||
|
||||
void GestionPlayer::droit()
|
||||
{
|
||||
Godot::print("Deplacement a droite");
|
||||
p.velocity.x -= p.speed;
|
||||
p.velocity.x += speed;
|
||||
}
|
||||
|
||||
void GestionPlayer::gauche()
|
||||
{
|
||||
Godot::print("Deplacement a gauche");
|
||||
p.velocity.x += p.speed;
|
||||
p.velocity.x -= speed;
|
||||
}
|
||||
|
||||
void GestionPlayer::bas()
|
||||
@ -114,10 +127,13 @@ void GestionPlayer::bas()
|
||||
void GestionPlayer::saut()
|
||||
{
|
||||
|
||||
p.velocity.y = power_jump;
|
||||
|
||||
}
|
||||
|
||||
void GestionPlayer::idle()
|
||||
{
|
||||
p.velocity.x = 0.0;
|
||||
}
|
||||
|
||||
void GestionPlayer::attack()
|
||||
|
@ -43,4 +43,17 @@ public:
|
||||
void saut();
|
||||
void idle();
|
||||
void attack();
|
||||
public:
|
||||
const int speed = 100;
|
||||
const int gravity = 90;
|
||||
const int power_jump = -250;
|
||||
bool on_ground = false;
|
||||
bool right;
|
||||
bool left;
|
||||
bool jump;
|
||||
|
||||
|
||||
private:
|
||||
Vector2 velocity;
|
||||
Vector2 FLOOR;
|
||||
};
|
Reference in New Issue
Block a user