mirror of
https://forge.univ-lyon1.fr/tplifap4/dungeonanddeamon.git
synced 2024-02-27 13:31:50 +01:00
ajout animation mobs+ input player + animation
This commit is contained in:
Binary file not shown.
@ -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)
|
, 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]
|
[rendering]
|
||||||
|
|
||||||
|
@ -2,5 +2,5 @@
|
|||||||
|
|
||||||
[ext_resource path="res://root.gdns" type="Script" id=1]
|
[ext_resource path="res://root.gdns" type="Script" id=1]
|
||||||
|
|
||||||
[node name="Node2D" type="Node2D"]
|
[node name="Node2D" type="AnimatedSprite"]
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include <Input.hpp>
|
#include <Input.hpp>
|
||||||
#include <ResourceLoader.hpp>
|
#include <ResourceLoader.hpp>
|
||||||
#include <Texture.hpp>
|
#include <Texture.hpp>
|
||||||
|
#include <InputEventKey.hpp>
|
||||||
GestionPlayer::GestionPlayer()
|
GestionPlayer::GestionPlayer()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -78,6 +78,14 @@ void GestionPlayer::traitementInput(float dt)
|
|||||||
gauche();
|
gauche();
|
||||||
if (i->is_action_pressed("ui_right"))
|
if (i->is_action_pressed("ui_right"))
|
||||||
droit();
|
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
|
// update Velocity
|
||||||
@ -109,6 +117,11 @@ void GestionPlayer::animation()
|
|||||||
sprite_player_ptr->play("Walk");
|
sprite_player_ptr->play("Walk");
|
||||||
sprite_player_ptr->set_flip_h(true);
|
sprite_player_ptr->set_flip_h(true);
|
||||||
}
|
}
|
||||||
|
else if(pv <= 0)
|
||||||
|
{
|
||||||
|
sprite_player_ptr->play("mort");
|
||||||
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprite_player_ptr->play("Idle");
|
sprite_player_ptr->play("Idle");
|
||||||
@ -166,6 +179,23 @@ void GestionPlayer::idle()
|
|||||||
p.velocity.x = 0.0;
|
p.velocity.x = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GestionPlayer::dash()
|
||||||
|
{
|
||||||
|
p.velocity.x =+1000;
|
||||||
|
sprite_player_ptr->play("dash");
|
||||||
|
}
|
||||||
|
|
||||||
void GestionPlayer::attack()
|
void GestionPlayer::attack()
|
||||||
{
|
{
|
||||||
|
sprite_player_ptr->play("attack");
|
||||||
|
}
|
||||||
|
|
||||||
|
void GestionPlayer::block()
|
||||||
|
{
|
||||||
|
sprite_player_ptr->play("block");
|
||||||
|
}
|
||||||
|
|
||||||
|
void GestionPlayer::bigattack()
|
||||||
|
{
|
||||||
|
sprite_player_ptr->play("attack2");
|
||||||
}
|
}
|
@ -44,11 +44,15 @@ private:
|
|||||||
void gauche();
|
void gauche();
|
||||||
void bas();
|
void bas();
|
||||||
void saut();
|
void saut();
|
||||||
|
void dash();
|
||||||
void idle();
|
void idle();
|
||||||
void attack();
|
void attack();
|
||||||
|
void bigattack();
|
||||||
void animation();
|
void animation();
|
||||||
|
void block();
|
||||||
public:
|
public:
|
||||||
const float speed = 100.f;
|
const float speed = 100.f;
|
||||||
|
float pv = 100;
|
||||||
const float GamePlayMultiplicator = 100.0f;
|
const float GamePlayMultiplicator = 100.0f;
|
||||||
const float gravity = 9.8f * GamePlayMultiplicator;
|
const float gravity = 9.8f * GamePlayMultiplicator;
|
||||||
const float power_jump = -5.0f * GamePlayMultiplicator;
|
const float power_jump = -5.0f * GamePlayMultiplicator;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "MobsCorpACorpIA.h"
|
#include "MobsCorpACorpIA.h"
|
||||||
#include <ConfigFile.hpp>
|
#include <ConfigFile.hpp>
|
||||||
|
#include <SpriteFrames.hpp>
|
||||||
#include <Input.hpp>
|
#include <Input.hpp>
|
||||||
#include <ResourceLoader.hpp>
|
#include <ResourceLoader.hpp>
|
||||||
#include <Texture.hpp>
|
#include <Texture.hpp>
|
||||||
@ -8,7 +9,7 @@
|
|||||||
|
|
||||||
MobsCorpACorpIA::MobsCorpACorpIA()
|
MobsCorpACorpIA::MobsCorpACorpIA()
|
||||||
{
|
{
|
||||||
sprite_MobsCorpACorp_ptr = Sprite::_new();
|
sprite_MobsCorpACorp_ptr = AnimatedSprite::_new();
|
||||||
collision_MobsCorpACorp_ptr = CollisionShape2D::_new();
|
collision_MobsCorpACorp_ptr = CollisionShape2D::_new();
|
||||||
texture_MobsCorpACorp_ptr.instance();
|
texture_MobsCorpACorp_ptr.instance();
|
||||||
texture_MobsCorpACorp_ptr->_new();
|
texture_MobsCorpACorp_ptr->_new();
|
||||||
@ -37,6 +38,7 @@ void MobsCorpACorpIA::_physics_process(float dt)
|
|||||||
|
|
||||||
void MobsCorpACorpIA::_process(float delta)
|
void MobsCorpACorpIA::_process(float delta)
|
||||||
{
|
{
|
||||||
|
animation();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MobsCorpACorpIA::_init()
|
void MobsCorpACorpIA::_init()
|
||||||
@ -63,20 +65,25 @@ void MobsCorpACorpIA::setupMobsCorpACorp()
|
|||||||
|
|
||||||
|
|
||||||
//Setup du shape
|
//Setup du shape
|
||||||
Godot::print("SetUp de Shape Mobs");
|
|
||||||
shape_MobsCorpACorp_ptr.ptr()->_new();
|
|
||||||
|
|
||||||
//Chargement de la texture
|
//Chargement de la texture
|
||||||
Godot::print("SetUp de Texture Mobs");
|
Godot::print("SetUp de Texture Mobs");
|
||||||
texture_MobsCorpACorp_ptr = ResourceLoader::get_singleton()->load("res://Character/Fire Elemental Sprite Sheet/fireelemental00.png");
|
texture_MobsCorpACorp_ptr = ResourceLoader::get_singleton()->load("res://Character/Fire Elemental Sprite Sheet/fireelemental00.png");
|
||||||
|
|
||||||
//setup du sprite
|
//setup du sprite
|
||||||
Godot::print("SetUp de Sprite Mobs");
|
//Godot::print("SetUp de Sprite");
|
||||||
sprite_MobsCorpACorp_ptr->set_texture(texture_MobsCorpACorp_ptr);
|
Ref<SpriteFrames> 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()
|
void MobsCorpACorpIA::droit()
|
||||||
|
@ -15,7 +15,7 @@ class MobsCorpACorpIA : public KinematicBody2D
|
|||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Sprite* sprite_MobsCorpACorp_ptr;
|
AnimatedSprite* sprite_MobsCorpACorp_ptr;
|
||||||
CollisionShape2D* collision_MobsCorpACorp_ptr;
|
CollisionShape2D* collision_MobsCorpACorp_ptr;
|
||||||
|
|
||||||
Ref<Resource> texture_MobsCorpACorp_ptr;
|
Ref<Resource> texture_MobsCorpACorp_ptr;
|
||||||
@ -35,6 +35,7 @@ public:
|
|||||||
void _process(float delta);
|
void _process(float delta);
|
||||||
void _init();
|
void _init();
|
||||||
void _ready();
|
void _ready();
|
||||||
|
void animation();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void droit();
|
void droit();
|
||||||
@ -61,6 +62,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
void Action();
|
void Action();
|
||||||
const float GamePlayMultiplicator = 100.0f;
|
const float GamePlayMultiplicator = 100.0f;
|
||||||
|
float pv = 100.0f;
|
||||||
const float gravity = 9.8f * GamePlayMultiplicator;
|
const float gravity = 9.8f * GamePlayMultiplicator;
|
||||||
const float speed = 50.f;
|
const float speed = 50.f;
|
||||||
const float power_jump = -2.0f * GamePlayMultiplicator;
|
const float power_jump = -2.0f * GamePlayMultiplicator;
|
||||||
|
Reference in New Issue
Block a user