diff --git a/DungeonAndDeamon/DungeonAndDaemon.pck b/DungeonAndDeamon/DungeonAndDaemon.pck index 9d5580b..b28ab60 100644 Binary files a/DungeonAndDeamon/DungeonAndDaemon.pck and b/DungeonAndDeamon/DungeonAndDaemon.pck differ diff --git a/DungeonAndDeamon/project.godot b/DungeonAndDeamon/project.godot index b0efb89..0731e7b 100644 --- a/DungeonAndDeamon/project.godot +++ b/DungeonAndDeamon/project.godot @@ -32,6 +32,26 @@ ui_right={ , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":15,"pressure":0.0,"pressed":false,"script":null) ] } +dash={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777237,"unicode":0,"echo":false,"script":null) + ] +} +attack={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":79,"unicode":0,"echo":false,"script":null) + ] +} +attack2={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":80,"unicode":0,"echo":false,"script":null) + ] +} +block={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":69,"unicode":0,"echo":false,"script":null) + ] +} [rendering] diff --git a/DungeonAndDeamon/root.tscn b/DungeonAndDeamon/root.tscn index f2a62dc..248b3e3 100644 --- a/DungeonAndDeamon/root.tscn +++ b/DungeonAndDeamon/root.tscn @@ -2,5 +2,5 @@ [ext_resource path="res://root.gdns" type="Script" id=1] -[node name="Node2D" type="Node2D"] +[node name="Node2D" type="AnimatedSprite"] script = ExtResource( 1 ) diff --git a/DungeonAndDeamonScript/DungeonAndDemaonScript/GestionPlayer.cpp b/DungeonAndDeamonScript/DungeonAndDemaonScript/GestionPlayer.cpp index 4124680..cf7b75f 100644 --- a/DungeonAndDeamonScript/DungeonAndDemaonScript/GestionPlayer.cpp +++ b/DungeonAndDeamonScript/DungeonAndDemaonScript/GestionPlayer.cpp @@ -4,7 +4,7 @@ #include #include #include - +#include GestionPlayer::GestionPlayer() { @@ -78,6 +78,14 @@ void GestionPlayer::traitementInput(float dt) gauche(); if (i->is_action_pressed("ui_right")) droit(); + if (i->is_action_pressed("dash")) + dash(); + if (i->is_action_pressed("attack")) + attack(); + if (i->is_action_pressed("attack2")) + bigattack(); + if (i->is_action_pressed("block")) + block(); // update Velocity @@ -109,6 +117,11 @@ void GestionPlayer::animation() sprite_player_ptr->play("Walk"); sprite_player_ptr->set_flip_h(true); } + else if(pv <= 0) + { + sprite_player_ptr->play("mort"); + } + else { sprite_player_ptr->play("Idle"); @@ -166,6 +179,23 @@ void GestionPlayer::idle() p.velocity.x = 0.0; } +void GestionPlayer::dash() +{ + p.velocity.x =+1000; + sprite_player_ptr->play("dash"); +} + void GestionPlayer::attack() { + sprite_player_ptr->play("attack"); } + +void GestionPlayer::block() +{ + sprite_player_ptr->play("block"); +} + +void GestionPlayer::bigattack() +{ + sprite_player_ptr->play("attack2"); +} \ No newline at end of file diff --git a/DungeonAndDeamonScript/DungeonAndDemaonScript/GestionPlayer.h b/DungeonAndDeamonScript/DungeonAndDemaonScript/GestionPlayer.h index b73f7ca..1f3b1c7 100644 --- a/DungeonAndDeamonScript/DungeonAndDemaonScript/GestionPlayer.h +++ b/DungeonAndDeamonScript/DungeonAndDemaonScript/GestionPlayer.h @@ -44,11 +44,15 @@ private: void gauche(); void bas(); void saut(); + void dash(); void idle(); void attack(); + void bigattack(); void animation(); + void block(); public: const float speed = 100.f; + float pv = 100; const float GamePlayMultiplicator = 100.0f; const float gravity = 9.8f * GamePlayMultiplicator; const float power_jump = -5.0f * GamePlayMultiplicator; diff --git a/DungeonAndDeamonScript/DungeonAndDemaonScript/MobsCorpACorpIA.cpp b/DungeonAndDeamonScript/DungeonAndDemaonScript/MobsCorpACorpIA.cpp index 4ce246f..a6a6dda 100644 --- a/DungeonAndDeamonScript/DungeonAndDemaonScript/MobsCorpACorpIA.cpp +++ b/DungeonAndDeamonScript/DungeonAndDemaonScript/MobsCorpACorpIA.cpp @@ -1,5 +1,6 @@ #include "MobsCorpACorpIA.h" #include +#include #include #include #include @@ -8,7 +9,7 @@ MobsCorpACorpIA::MobsCorpACorpIA() { - sprite_MobsCorpACorp_ptr = Sprite::_new(); + sprite_MobsCorpACorp_ptr = AnimatedSprite::_new(); collision_MobsCorpACorp_ptr = CollisionShape2D::_new(); texture_MobsCorpACorp_ptr.instance(); texture_MobsCorpACorp_ptr->_new(); @@ -37,6 +38,7 @@ void MobsCorpACorpIA::_physics_process(float dt) void MobsCorpACorpIA::_process(float delta) { + animation(); } void MobsCorpACorpIA::_init() @@ -63,20 +65,25 @@ void MobsCorpACorpIA::setupMobsCorpACorp() //Setup du shape - Godot::print("SetUp de Shape Mobs"); - shape_MobsCorpACorp_ptr.ptr()->_new(); + //Chargement de la texture Godot::print("SetUp de Texture Mobs"); texture_MobsCorpACorp_ptr = ResourceLoader::get_singleton()->load("res://Character/Fire Elemental Sprite Sheet/fireelemental00.png"); //setup du sprite - Godot::print("SetUp de Sprite Mobs"); - sprite_MobsCorpACorp_ptr->set_texture(texture_MobsCorpACorp_ptr); + //Godot::print("SetUp de Sprite"); + Ref spriteFrames = ResourceLoader::get_singleton()->load("res://Character/Fire Elemental Sprite Sheet/fireelement.tres"); + sprite_MobsCorpACorp_ptr->set_sprite_frames(spriteFrames); + + PoolStringArray AnimNames = spriteFrames->get_animation_names(); + PoolStringArray::Read r = AnimNames.read(); + Godot::print("Animations Names"); + for (int i = 0; i < AnimNames.size(); ++i) + { + Godot::print(r[i]); + } - //setup du collision Shape - Godot::print("SetUp de CollisionShape Mobs"); - collision_MobsCorpACorp_ptr->set_shape(shape_MobsCorpACorp_ptr); } @@ -133,6 +140,32 @@ void MobsCorpACorpIA::mouvement(float dt) } +} + + +void MobsCorpACorpIA::animation() +{ + + if (m.velocity.x > 0.0f) + { + sprite_MobsCorpACorp_ptr->play("walk"); + sprite_MobsCorpACorp_ptr->set_flip_h(false); + } + else if (m.velocity.x < 0.0f) + { + sprite_MobsCorpACorp_ptr->play("walk"); + sprite_MobsCorpACorp_ptr->set_flip_h(true); + } + else if (pv <=0 ) + { + sprite_MobsCorpACorp_ptr->play("dead"); + } + else + { + sprite_MobsCorpACorp_ptr->play("idle"); + } + + } void MobsCorpACorpIA::droit() diff --git a/DungeonAndDeamonScript/DungeonAndDemaonScript/MobsCorpACorpIA.h b/DungeonAndDeamonScript/DungeonAndDemaonScript/MobsCorpACorpIA.h index fa48d51..2973e01 100644 --- a/DungeonAndDeamonScript/DungeonAndDemaonScript/MobsCorpACorpIA.h +++ b/DungeonAndDeamonScript/DungeonAndDemaonScript/MobsCorpACorpIA.h @@ -15,7 +15,7 @@ class MobsCorpACorpIA : public KinematicBody2D { public: - Sprite* sprite_MobsCorpACorp_ptr; + AnimatedSprite* sprite_MobsCorpACorp_ptr; CollisionShape2D* collision_MobsCorpACorp_ptr; Ref texture_MobsCorpACorp_ptr; @@ -35,6 +35,7 @@ public: void _process(float delta); void _init(); void _ready(); + void animation(); private: void droit(); @@ -61,6 +62,7 @@ public: public: void Action(); const float GamePlayMultiplicator = 100.0f; + float pv = 100.0f; const float gravity = 9.8f * GamePlayMultiplicator; const float speed = 50.f; const float power_jump = -2.0f * GamePlayMultiplicator;