Debut mouvement Mob

This commit is contained in:
Estrela Allan p1923381
2020-04-30 18:05:19 +02:00
parent 97f45944db
commit 6c12f02787
4 changed files with 83 additions and 14 deletions

View File

@ -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;
}