mirror of
https://forge.univ-lyon1.fr/tplifap4/dungeonanddeamon.git
synced 2024-02-27 13:31:50 +01:00
Debut mouvement Mob
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
#include <ResourceLoader.hpp>
|
||||
#include <Texture.hpp>
|
||||
#include "MobsCorpACorp.h"
|
||||
#include "GestionPlayer.h"
|
||||
|
||||
MobsCorpACorpIA::MobsCorpACorpIA()
|
||||
{
|
||||
@ -28,9 +29,9 @@ void MobsCorpACorpIA::_register_methods()
|
||||
|
||||
}
|
||||
|
||||
void MobsCorpACorpIA::_physics_process(float delta)
|
||||
void MobsCorpACorpIA::_physics_process(float dt)
|
||||
{
|
||||
mouvement();
|
||||
mouvement(dt);
|
||||
m.velocity = move_and_slide(m.velocity);
|
||||
}
|
||||
|
||||
@ -82,24 +83,77 @@ void MobsCorpACorpIA::setupMobsCorpACorp()
|
||||
void MobsCorpACorpIA::setPosition(int x, int y)
|
||||
{
|
||||
Transform2D t;
|
||||
Vector2 v;
|
||||
Vector2 pos;
|
||||
Size2 s;
|
||||
|
||||
//setup de la size
|
||||
s.x = 1;
|
||||
s.y = 1;
|
||||
v.x = x;
|
||||
v.y = y;
|
||||
t.set_origin(v);
|
||||
pos.x = x;
|
||||
pos.y = y;
|
||||
t.set_origin(pos);
|
||||
t.scale(s);
|
||||
|
||||
set_transform(t);
|
||||
}
|
||||
|
||||
void MobsCorpACorpIA::mouvement()
|
||||
void MobsCorpACorpIA::mouvement(float dt)
|
||||
{
|
||||
Vector2 pos;
|
||||
|
||||
|
||||
|
||||
m.velocity = Vector2(0, 0);
|
||||
m.velocity.y += gravity;
|
||||
|
||||
|
||||
|
||||
|
||||
if (on_ground)
|
||||
{
|
||||
m.velocity.y = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
//m.velocity.y += gravity * dt;
|
||||
}
|
||||
|
||||
if (pos.x < TargetPosition.x) {
|
||||
droit();
|
||||
}else if (pos.x > TargetPosition.x) {
|
||||
gauche();
|
||||
}
|
||||
|
||||
if (pos.y < TargetPosition.y) {
|
||||
|
||||
//saut();
|
||||
}
|
||||
else if (pos.x > TargetPosition.x) {
|
||||
//bas();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void MobsCorpACorpIA::droit()
|
||||
{
|
||||
Godot::print("Deplacement mob a droite");
|
||||
m.velocity.x = speed;
|
||||
}
|
||||
|
||||
void MobsCorpACorpIA::gauche()
|
||||
{
|
||||
Godot::print("Deplacement mob a gauche");
|
||||
m.velocity.x = -speed;
|
||||
}
|
||||
|
||||
void MobsCorpACorpIA::bas()
|
||||
{
|
||||
}
|
||||
|
||||
void MobsCorpACorpIA::saut()
|
||||
{
|
||||
|
||||
m.velocity.y = power_jump;
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user