mirror of
https://forge.univ-lyon1.fr/tplifap4/dungeonanddeamon.git
synced 2024-02-27 13:31:50 +01:00
Mouvement de notre joueur (tj probleme de saut)
This commit is contained in:
Binary file not shown.
@ -96,19 +96,14 @@ animations = [ {
|
|||||||
"name": "degat",
|
"name": "degat",
|
||||||
"speed": 5.0
|
"speed": 5.0
|
||||||
}, {
|
}, {
|
||||||
"frames": [ ExtResource( 45 ), ExtResource( 41 ), ExtResource( 42 ), ExtResource( 63 ), ExtResource( 58 ), ExtResource( 59 ), ExtResource( 40 ), ExtResource( 55 ), ExtResource( 36 ) ],
|
"frames": [ ExtResource( 37 ), ExtResource( 60 ), ExtResource( 61 ), ExtResource( 50 ), ExtResource( 38 ), ExtResource( 33 ), ExtResource( 39 ) ],
|
||||||
"loop": true,
|
"loop": true,
|
||||||
"name": "attack02",
|
"name": "jump",
|
||||||
"speed": 5.0
|
"speed": 5.0
|
||||||
}, {
|
}, {
|
||||||
"frames": [ ExtResource( 13 ), ExtResource( 16 ), ExtResource( 17 ), ExtResource( 14 ), ExtResource( 12 ), ExtResource( 15 ), ExtResource( 21 ), ExtResource( 18 ), ExtResource( 20 ), ExtResource( 19 ) ],
|
"frames": [ ExtResource( 56 ), ExtResource( 48 ), ExtResource( 44 ), ExtResource( 34 ), ExtResource( 54 ), ExtResource( 35 ), ExtResource( 49 ), ExtResource( 46 ), ExtResource( 47 ) ],
|
||||||
"loop": true,
|
"loop": true,
|
||||||
"name": "run",
|
"name": "mort",
|
||||||
"speed": 5.0
|
|
||||||
}, {
|
|
||||||
"frames": [ ExtResource( 71 ), ExtResource( 66 ), ExtResource( 67 ), ExtResource( 72 ), ExtResource( 74 ), ExtResource( 77 ), ExtResource( 80 ), ExtResource( 79 ), ExtResource( 75 ) ],
|
|
||||||
"loop": true,
|
|
||||||
"name": "roulade",
|
|
||||||
"speed": 5.0
|
"speed": 5.0
|
||||||
}, {
|
}, {
|
||||||
"frames": [ ExtResource( 65 ), ExtResource( 81 ), ExtResource( 76 ), ExtResource( 70 ), ExtResource( 68 ) ],
|
"frames": [ ExtResource( 65 ), ExtResource( 81 ), ExtResource( 76 ), ExtResource( 70 ), ExtResource( 68 ) ],
|
||||||
@ -121,24 +116,29 @@ animations = [ {
|
|||||||
"name": "attack01",
|
"name": "attack01",
|
||||||
"speed": 5.0
|
"speed": 5.0
|
||||||
}, {
|
}, {
|
||||||
|
"frames": [ ExtResource( 57 ), ExtResource( 52 ), ExtResource( 69 ), ExtResource( 64 ), ExtResource( 78 ), ExtResource( 73 ), ExtResource( 65 ) ],
|
||||||
|
"loop": true,
|
||||||
|
"name": "shield",
|
||||||
|
"speed": 5.0
|
||||||
|
}, {
|
||||||
|
"frames": [ ExtResource( 71 ), ExtResource( 66 ), ExtResource( 67 ), ExtResource( 72 ), ExtResource( 74 ), ExtResource( 77 ), ExtResource( 80 ), ExtResource( 79 ), ExtResource( 75 ) ],
|
||||||
|
"loop": true,
|
||||||
|
"name": "roulade",
|
||||||
|
"speed": 5.0
|
||||||
|
}, {
|
||||||
"frames": [ ExtResource( 33 ), ExtResource( 38 ), ExtResource( 33 ), ExtResource( 39 ), ExtResource( 38 ), ExtResource( 50 ) ],
|
"frames": [ ExtResource( 33 ), ExtResource( 38 ), ExtResource( 33 ), ExtResource( 39 ), ExtResource( 38 ), ExtResource( 50 ) ],
|
||||||
"loop": true,
|
"loop": true,
|
||||||
"name": "fall",
|
"name": "fall",
|
||||||
"speed": 5.0
|
"speed": 5.0
|
||||||
}, {
|
}, {
|
||||||
"frames": [ ExtResource( 56 ), ExtResource( 48 ), ExtResource( 44 ), ExtResource( 34 ), ExtResource( 54 ), ExtResource( 35 ), ExtResource( 49 ), ExtResource( 46 ), ExtResource( 47 ) ],
|
"frames": [ ExtResource( 45 ), ExtResource( 41 ), ExtResource( 42 ), ExtResource( 63 ), ExtResource( 58 ), ExtResource( 59 ), ExtResource( 40 ), ExtResource( 55 ), ExtResource( 36 ) ],
|
||||||
"loop": true,
|
"loop": true,
|
||||||
"name": "mort",
|
"name": "attack02",
|
||||||
"speed": 5.0
|
"speed": 5.0
|
||||||
}, {
|
}, {
|
||||||
"frames": [ ExtResource( 37 ), ExtResource( 60 ), ExtResource( 61 ), ExtResource( 50 ), ExtResource( 38 ), ExtResource( 33 ), ExtResource( 39 ) ],
|
"frames": [ ExtResource( 13 ), ExtResource( 16 ), ExtResource( 17 ), ExtResource( 14 ), ExtResource( 12 ), ExtResource( 15 ), ExtResource( 21 ), ExtResource( 18 ), ExtResource( 20 ), ExtResource( 19 ) ],
|
||||||
"loop": true,
|
"loop": true,
|
||||||
"name": "jump",
|
"name": "run",
|
||||||
"speed": 5.0
|
|
||||||
}, {
|
|
||||||
"frames": [ ExtResource( 57 ), ExtResource( 52 ), ExtResource( 69 ), ExtResource( 64 ), ExtResource( 78 ), ExtResource( 73 ), ExtResource( 65 ) ],
|
|
||||||
"loop": true,
|
|
||||||
"name": "shield",
|
|
||||||
"speed": 5.0
|
"speed": 5.0
|
||||||
} ]
|
} ]
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ position = Vector2( 1.91107, 18.2282 )
|
|||||||
texture = ExtResource( 1 )
|
texture = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="Player" type="KinematicBody2D" parent="."]
|
[node name="Player" type="KinematicBody2D" parent="."]
|
||||||
position = Vector2( 382.61, 374.846 )
|
position = Vector2( 499.61, 264.846 )
|
||||||
script = ExtResource( 3 )
|
script = ExtResource( 3 )
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_group_": true
|
"_edit_group_": true
|
||||||
@ -173,7 +173,6 @@ shape = SubResource( 1 )
|
|||||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="Player"]
|
[node name="AnimatedSprite" type="AnimatedSprite" parent="Player"]
|
||||||
frames = SubResource( 2 )
|
frames = SubResource( 2 )
|
||||||
animation = "fall"
|
animation = "fall"
|
||||||
frame = 5
|
|
||||||
playing = true
|
playing = true
|
||||||
|
|
||||||
[node name="TileMap" type="TileMap" parent="."]
|
[node name="TileMap" type="TileMap" parent="."]
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
[gd_resource type="NativeScript" load_steps=2 format=2]
|
[gd_resource type="NativeScript" load_steps=2 format=2]
|
||||||
|
|
||||||
[sub_resource type="GDNativeLibrary" id=1]
|
[sub_resource type="GDNativeLibrary" id=1]
|
||||||
entry/Windows.64 = "res://Dungeonanddemon.dll"
|
entry/Windows.64 = "res://.script/DungeonAndDeamonScript.dll"
|
||||||
dependency/Windows.64 = [ ]
|
dependency/Windows.64 = [ ]
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
resource_name = "Player"
|
resource_name = "Player"
|
||||||
class_name = "Player"
|
class_name = "GestionPlayer"
|
||||||
library = SubResource( 1 )
|
library = SubResource( 1 )
|
||||||
|
@ -10,7 +10,7 @@ class GestionCollision
|
|||||||
public :
|
public :
|
||||||
GestionTerrain gTerrain;
|
GestionTerrain gTerrain;
|
||||||
GestionMobs gMobs;
|
GestionMobs gMobs;
|
||||||
GestionPlayer gPlayer;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::vector<Mobs> CheckCollisonSol();
|
std::vector<Mobs> CheckCollisonSol();
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
class GestionJeu
|
class GestionJeu
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GestionPlayer gPlayer;
|
|
||||||
GestionMobs gMobs;
|
GestionMobs gMobs;
|
||||||
GestionTerrain gTerrain;
|
GestionTerrain gTerrain;
|
||||||
GestionCollision gCollision;
|
GestionCollision gCollision;
|
||||||
|
@ -1,24 +1,26 @@
|
|||||||
#include "GestionPlayer.h"
|
#include "GestionPlayer.h"
|
||||||
|
#include <AnimatedSprite.hpp>
|
||||||
|
#include <Node2D.hpp>
|
||||||
|
|
||||||
|
|
||||||
#include "GestionPlayer.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
using namespace godot;
|
using namespace godot;
|
||||||
|
|
||||||
void Player::_register_methods() {
|
void GestionPlayer::_register_methods() {
|
||||||
register_method((char*)"_process", &Player::_process);
|
register_method((char*)"_process", &GestionPlayer::_process);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::_init() {}
|
void GestionPlayer::_init() {}
|
||||||
|
|
||||||
Player::Player() {
|
GestionPlayer::GestionPlayer() {
|
||||||
velocity = Vector2(0, 0);
|
velocity = Vector2(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Player::~Player() {}
|
GestionPlayer::~GestionPlayer() {}
|
||||||
|
|
||||||
void Player::_process(float delta)
|
void GestionPlayer::_process(float delta)
|
||||||
{
|
{
|
||||||
|
|
||||||
UpdateMotionFromInput();
|
UpdateMotionFromInput();
|
||||||
@ -26,7 +28,7 @@ void Player::_process(float delta)
|
|||||||
velocity = move_and_slide(velocity, FLOOR);
|
velocity = move_and_slide(velocity, FLOOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::UpdateMotionFromInput()
|
void GestionPlayer::UpdateMotionFromInput()
|
||||||
{
|
{
|
||||||
velocity = Vector2(0, 0);
|
velocity = Vector2(0, 0);
|
||||||
FLOOR = Vector2(0, -1);
|
FLOOR = Vector2(0, -1);
|
||||||
@ -36,11 +38,7 @@ void Player::UpdateMotionFromInput()
|
|||||||
|
|
||||||
if (i->is_action_pressed("ui_left"))
|
if (i->is_action_pressed("ui_left"))
|
||||||
{
|
{
|
||||||
|
|
||||||
velocity.x -= speed;
|
velocity.x -= speed;
|
||||||
void play(String anim = "run", bool backwards = false);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#pragma once
|
|
||||||
#include "Player.h"
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
@ -8,19 +7,19 @@
|
|||||||
#include <Input.hpp>
|
#include <Input.hpp>
|
||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
class Player : public KinematicBody2D
|
class GestionPlayer : public KinematicBody2D
|
||||||
{
|
{
|
||||||
|
|
||||||
// Godot structure
|
// Godot structure
|
||||||
private:
|
private:
|
||||||
GODOT_CLASS(Player, KinematicBody2D)
|
GODOT_CLASS(GestionPlayer, KinematicBody2D)
|
||||||
public:
|
public:
|
||||||
static void _register_methods();
|
static void _register_methods();
|
||||||
void _init();
|
void _init();
|
||||||
void _process(float delta);
|
void _process(float delta);
|
||||||
|
|
||||||
Player();
|
GestionPlayer();
|
||||||
~Player();
|
~GestionPlayer();
|
||||||
|
|
||||||
|
|
||||||
// Gameplay variables
|
// Gameplay variables
|
||||||
@ -34,13 +33,15 @@ namespace godot {
|
|||||||
bool left;
|
bool left;
|
||||||
bool jump;
|
bool jump;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector2 velocity;
|
Vector2 velocity;
|
||||||
Vector2 FLOOR;
|
Vector2 FLOOR;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Gameplay methods
|
// Gameplay methods
|
||||||
public:
|
public:
|
||||||
void UpdateMotionFromInput();
|
void UpdateMotionFromInput();
|
||||||
@ -54,6 +55,5 @@ namespace godot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
attack();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "Player.h"
|
#include "GestionPlayer.h"
|
||||||
|
|
||||||
using namespace godot;
|
using namespace godot;
|
||||||
|
|
||||||
@ -12,5 +12,5 @@ extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_opt
|
|||||||
|
|
||||||
extern "C" void GDN_EXPORT godot_nativescript_init(void* handle) {
|
extern "C" void GDN_EXPORT godot_nativescript_init(void* handle) {
|
||||||
Godot::nativescript_init(handle);
|
Godot::nativescript_init(handle);
|
||||||
register_class<Player>();
|
register_class<GestionPlayer>();
|
||||||
}
|
}
|
Reference in New Issue
Block a user