mirror of
https://forge.univ-lyon1.fr/tplifap4/dungeonanddeamon.git
synced 2024-02-27 13:31:50 +01:00
Ajout gestionTerrain + Ajout Sol solide
This commit is contained in:
parent
be3f291382
commit
2b664e87ee
@ -13,6 +13,7 @@ using namespace godot;
|
|||||||
GestionJeu::GestionJeu()
|
GestionJeu::GestionJeu()
|
||||||
{
|
{
|
||||||
gPlayer = GestionPlayer::_new();
|
gPlayer = GestionPlayer::_new();
|
||||||
|
gTerrain = GestionTerrain::_new();
|
||||||
}
|
}
|
||||||
|
|
||||||
GestionJeu::~GestionJeu()
|
GestionJeu::~GestionJeu()
|
||||||
@ -50,7 +51,9 @@ void GestionJeu::_process()
|
|||||||
|
|
||||||
void GestionJeu::create_scene()
|
void GestionJeu::create_scene()
|
||||||
{
|
{
|
||||||
|
Godot::print("Add childs");
|
||||||
add_child(gPlayer);
|
add_child(gPlayer);
|
||||||
|
add_child(gTerrain);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GestionJeu::setup_scene()
|
void GestionJeu::setup_scene()
|
||||||
|
@ -21,7 +21,7 @@ public:
|
|||||||
//Gestion des deifferents parties du jeu
|
//Gestion des deifferents parties du jeu
|
||||||
GestionPlayer* gPlayer;
|
GestionPlayer* gPlayer;
|
||||||
GestionMobs gMobs;
|
GestionMobs gMobs;
|
||||||
GestionTerrain gTerrain;
|
GestionTerrain* gTerrain;
|
||||||
GestionCollision gCollision;
|
GestionCollision gCollision;
|
||||||
GestionItem gItem;
|
GestionItem gItem;
|
||||||
GestionIdentifiant gId;
|
GestionIdentifiant gId;
|
||||||
|
@ -1,11 +1,72 @@
|
|||||||
#include "GestionTerrain.h"
|
#include "GestionTerrain.h"
|
||||||
|
#include <TileMap.hpp>
|
||||||
|
#include <ResourceLoader.hpp>
|
||||||
|
#include <Sprite.hpp>
|
||||||
|
#include <Texture.hpp>
|
||||||
|
|
||||||
|
using namespace godot;
|
||||||
|
|
||||||
|
GestionTerrain::GestionTerrain()
|
||||||
|
{
|
||||||
|
Godot::print("Constructeur");
|
||||||
|
}
|
||||||
|
|
||||||
|
GestionTerrain::~GestionTerrain()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void GestionTerrain::_register_methods()
|
||||||
|
{
|
||||||
|
Godot::print("Register");
|
||||||
|
register_method("_process", &GestionTerrain::_process);
|
||||||
|
register_method("_init", &GestionTerrain::_init);
|
||||||
|
register_method("_ready", &GestionTerrain::_ready);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GestionTerrain::_process()
|
||||||
|
{
|
||||||
|
Godot::print("Je suis le sol");
|
||||||
|
}
|
||||||
|
|
||||||
|
void GestionTerrain::_init()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void GestionTerrain::_ready()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void GestionTerrain::AjoutMur(int sizeX, int sizeY, int posX, int posY)
|
void GestionTerrain::AjoutMur(int sizeX, int sizeY, int posX, int posY)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GestionTerrain::AjoutSolSolide(int sizeX, int sizeY, int posX, int posY)
|
void GestionTerrain::AjoutSolSolide(int sizeX, int sizeY, int posX, int posY)
|
||||||
{
|
{
|
||||||
|
Godot::print("Ajout sol solide");
|
||||||
|
Transform2D t;
|
||||||
|
Vector2 v;
|
||||||
|
Size2 s;
|
||||||
|
|
||||||
|
//setup de la size
|
||||||
|
s.x = sizeX;
|
||||||
|
s.y = sizeY;
|
||||||
|
v.x = posX;
|
||||||
|
v.y = posY;
|
||||||
|
t.set_origin(v);
|
||||||
|
t.scale(s);
|
||||||
|
|
||||||
|
StaticBody2D* m = StaticBody2D::_new();
|
||||||
|
|
||||||
|
Sprite* sprite = Sprite::_new();
|
||||||
|
|
||||||
|
Ref<Texture> texture_ptr = ResourceLoader::get_singleton()->load("res://sol.png");
|
||||||
|
sprite->set_texture(texture_ptr);
|
||||||
|
|
||||||
|
m->add_child(sprite);
|
||||||
|
m->set_transform(t);
|
||||||
|
|
||||||
|
add_child(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GestionTerrain::AjoutSolTraversable(int sizeX, int sizeY, int posX, int posY)
|
void GestionTerrain::AjoutSolTraversable(int sizeX, int sizeY, int posX, int posY)
|
||||||
|
@ -1,12 +1,26 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include <Godot.hpp>
|
||||||
|
#include <KinematicBody2D.hpp>
|
||||||
|
#include <TileMap.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "Terrain.h"
|
#include "Terrain.h"
|
||||||
|
|
||||||
class GestionTerrain
|
using namespace godot;
|
||||||
|
|
||||||
|
class GestionTerrain : public TileMap
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
GODOT_CLASS(GestionTerrain, TileMap)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::vector<Terrain> terrains;
|
GestionTerrain();
|
||||||
|
~GestionTerrain();
|
||||||
|
|
||||||
|
void static _register_methods();
|
||||||
|
void _process();
|
||||||
|
void _init();
|
||||||
|
void _ready();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void AjoutMur(int sizeX, int sizeY, int posX, int posY);
|
void AjoutMur(int sizeX, int sizeY, int posX, int posY);
|
||||||
|
@ -14,4 +14,6 @@ extern "C" void GDN_EXPORT godot_nativescript_init(void* handle) {
|
|||||||
Godot::nativescript_init(handle);
|
Godot::nativescript_init(handle);
|
||||||
register_class<GestionJeu>();
|
register_class<GestionJeu>();
|
||||||
register_class<GestionPlayer>();
|
register_class<GestionPlayer>();
|
||||||
|
register_class<GestionTerrain>();
|
||||||
|
register_class<Terrain>();
|
||||||
}
|
}
|
@ -1 +1,5 @@
|
|||||||
#include "Terrain.h"
|
#include "Terrain.h"
|
||||||
|
|
||||||
|
void Terrain::_register_methods()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
@ -1,8 +1,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <StaticBody2D.hpp>
|
#include <StaticBody2D.hpp>
|
||||||
|
#include <Godot.hpp>
|
||||||
|
|
||||||
class Terrain :
|
class Terrain :
|
||||||
public godot::StaticBody2D
|
public godot::StaticBody2D
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
GODOT_CLASS(Terrain, StaticBody2D)
|
||||||
|
|
||||||
|
public:
|
||||||
|
void static _register_methods();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user