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:
@ -10,7 +10,7 @@ class GestionCollision
|
||||
public :
|
||||
GestionTerrain gTerrain;
|
||||
GestionMobs gMobs;
|
||||
GestionPlayer gPlayer;
|
||||
|
||||
|
||||
public:
|
||||
std::vector<Mobs> CheckCollisonSol();
|
||||
|
@ -9,7 +9,7 @@
|
||||
class GestionJeu
|
||||
{
|
||||
public:
|
||||
GestionPlayer gPlayer;
|
||||
|
||||
GestionMobs gMobs;
|
||||
GestionTerrain gTerrain;
|
||||
GestionCollision gCollision;
|
||||
|
@ -1,24 +1,26 @@
|
||||
#include "GestionPlayer.h"
|
||||
#include <AnimatedSprite.hpp>
|
||||
#include <Node2D.hpp>
|
||||
|
||||
|
||||
#include "GestionPlayer.h"
|
||||
|
||||
|
||||
|
||||
using namespace godot;
|
||||
|
||||
void Player::_register_methods() {
|
||||
register_method((char*)"_process", &Player::_process);
|
||||
void GestionPlayer::_register_methods() {
|
||||
register_method((char*)"_process", &GestionPlayer::_process);
|
||||
}
|
||||
|
||||
void Player::_init() {}
|
||||
void GestionPlayer::_init() {}
|
||||
|
||||
Player::Player() {
|
||||
GestionPlayer::GestionPlayer() {
|
||||
velocity = Vector2(0, 0);
|
||||
}
|
||||
|
||||
Player::~Player() {}
|
||||
GestionPlayer::~GestionPlayer() {}
|
||||
|
||||
void Player::_process(float delta)
|
||||
void GestionPlayer::_process(float delta)
|
||||
{
|
||||
|
||||
UpdateMotionFromInput();
|
||||
@ -26,7 +28,7 @@ void Player::_process(float delta)
|
||||
velocity = move_and_slide(velocity, FLOOR);
|
||||
}
|
||||
|
||||
void Player::UpdateMotionFromInput()
|
||||
void GestionPlayer::UpdateMotionFromInput()
|
||||
{
|
||||
velocity = Vector2(0, 0);
|
||||
FLOOR = Vector2(0, -1);
|
||||
@ -36,11 +38,7 @@ void Player::UpdateMotionFromInput()
|
||||
|
||||
if (i->is_action_pressed("ui_left"))
|
||||
{
|
||||
|
||||
velocity.x -= speed;
|
||||
void play(String anim = "run", bool backwards = false);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
#pragma once
|
||||
#include "Player.h"
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
@ -8,19 +7,19 @@
|
||||
#include <Input.hpp>
|
||||
|
||||
namespace godot {
|
||||
class Player : public KinematicBody2D
|
||||
class GestionPlayer : public KinematicBody2D
|
||||
{
|
||||
|
||||
// Godot structure
|
||||
private:
|
||||
GODOT_CLASS(Player, KinematicBody2D)
|
||||
GODOT_CLASS(GestionPlayer, KinematicBody2D)
|
||||
public:
|
||||
static void _register_methods();
|
||||
void _init();
|
||||
void _process(float delta);
|
||||
|
||||
Player();
|
||||
~Player();
|
||||
GestionPlayer();
|
||||
~GestionPlayer();
|
||||
|
||||
|
||||
// Gameplay variables
|
||||
@ -34,12 +33,14 @@ namespace godot {
|
||||
bool left;
|
||||
bool jump;
|
||||
|
||||
|
||||
private:
|
||||
Vector2 velocity;
|
||||
Vector2 FLOOR;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Gameplay methods
|
||||
public:
|
||||
@ -54,6 +55,5 @@ namespace godot {
|
||||
}
|
||||
|
||||
|
||||
attack();
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "Player.h"
|
||||
#include "GestionPlayer.h"
|
||||
|
||||
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) {
|
||||
Godot::nativescript_init(handle);
|
||||
register_class<Player>();
|
||||
register_class<GestionPlayer>();
|
||||
}
|
Reference in New Issue
Block a user