dungeonanddeamon/DungeonAndDeamonScript/DungeonAndDemaonScript/GestionJeu.cpp
2020-04-21 15:42:31 +02:00

78 lines
1.3 KiB
C++

#include "GestionJeu.h"
#include <Sprite.hpp>
#include <CollisionShape2D.hpp>
#include <ResourceLoader.hpp>
#include <CircleShape2D.hpp>
#include <GodotGlobal.hpp>
#include <Texture.hpp>
#include <AnimatedSprite.hpp>
#include "MobsCorpACorpIA.h"
using namespace godot;
GestionJeu::GestionJeu()
{
gPlayer = GestionPlayer::_new();
gTerrain = GestionTerrain::_new();
gMobs = new GestionMobs();
gCollision = new GestionCollision(gMobs, gPlayer, gTerrain);
}
GestionJeu::~GestionJeu()
{
delete gPlayer;
}
void GestionJeu::_register_methods()
{
register_method((char*)"_init", &GestionJeu::_init);
register_method((char*)"_ready", &GestionJeu::_ready);
register_method((char*)"_process", &GestionJeu::_process);
}
void GestionJeu::_init()
{
Godot::print("Initialisation...");
create_scene();
Godot::print("Initialisation OK !");
}
void GestionJeu::_ready()
{
Godot::print("Ready...");
setup_scene();
Godot::print("Ready OK !");
}
void GestionJeu::_process()
{
gCollision->CheckCollisonSol();
}
void GestionJeu::create_scene()
{
add_child(gPlayer);
add_child(gTerrain);
gMobs->AjoutMobC2C(10, 20, 5, 0, 1, 25);
for (KinematicBody2D* m : gMobs->mobs)
{
auto mob = (MobsCorpACorpIA*) m;
Godot::print("Add child mob");
add_child(m);
}
}
void GestionJeu::setup_scene()
{
gPlayer->setPosition(15, 150);
gTerrain->GenerationCarte();
}