Started project, implemented keyboard and controller movement

This commit is contained in:
Sarah Faey 2025-04-17 22:53:25 +02:00
parent b1f5d882f0
commit d8fa53801b
33 changed files with 931 additions and 73 deletions

View file

@ -0,0 +1,11 @@
#ifndef AXIS_COMMAND_H
#define AXIS_COMMAND_H
class AxisCommand
{
public:
virtual void Execute(float value) = 0;
};
#endif

View file

View file

@ -0,0 +1,17 @@
#ifndef END_GAME_COMMAND_H
#define END_GAME_COMMAND_H
#include "GameCommand.h"
#include "../Game.h"
class EndGameCommand : public GameCommand
{
public:
EndGameCommand(Game* game) : m_game(game){}
void Down() override {m_game->EndGame();}
void Up() override {}
private:
Game* m_game;
};
#endif

View file

@ -0,0 +1,13 @@
#ifndef GAME_COMMAND_H
#define GAME_COMMAND_H
class GameCommand
{
public:
GameCommand() {};
virtual ~GameCommand() {};
virtual void Down() = 0;
virtual void Up() = 0;
};
#endif

View file

@ -0,0 +1,19 @@
#ifndef MOVE_DOWN_COMMAND_H
#define MOVE_DOWN_COMMAND_H
#include "GameCommand.h"
#include <SDL3/SDL.h>
class MoveDownCommand : public GameCommand
{
public:
MoveDownCommand(SDL_FPoint & directionInput, bool & buttonInput) : m_directionInput(&directionInput), m_buttonInput(&buttonInput) {};
~MoveDownCommand() {};
void Down() override { m_directionInput->y += 1; *m_buttonInput = true;}
void Up() override { m_directionInput->y -= 1; *m_buttonInput = true;}
private:
SDL_FPoint * m_directionInput;
bool * m_buttonInput;
};
#endif

View file

@ -0,0 +1,22 @@
#ifndef MOVE_LEFT_COMMAND_H
#define MOVE_LEFT_COMMAND_H
#include "GameCommand.h"
#include <iostream>
#include <memory>
#include <SDL3/SDL.h>
#include "../Components/MoveComponent.h"
class MoveLeftCommand : public GameCommand
{
public:
MoveLeftCommand(SDL_FPoint & directionInput, bool & buttonInput) : m_directionInput(&directionInput), m_buttonInput(&buttonInput) {};
~MoveLeftCommand() {};
void Down() override { m_directionInput->x -= 1; *m_buttonInput = true;}
void Up() override { m_directionInput->x += 1; *m_buttonInput = true;}
private:
SDL_FPoint * m_directionInput;
bool * m_buttonInput;
};
#endif

View file

@ -0,0 +1,22 @@
#ifndef MOVE_RIGHT_COMMAND_H
#define MOVE_RIGHT_COMMAND_H
#include "GameCommand.h"
#include <iostream>
#include <memory>
#include <SDL3/SDL.h>
#include "../Components/MoveComponent.h"
class MoveRightCommand : public GameCommand
{
public:
MoveRightCommand(SDL_FPoint & directionInput, bool & buttonInput) : m_directionInput(&directionInput), m_buttonInput(&buttonInput) {};
~MoveRightCommand() {};
void Down() override { m_directionInput->x += 1; *m_buttonInput = true;}
void Up() override { m_directionInput->x -= 1; *m_buttonInput = true;}
private:
SDL_FPoint * m_directionInput;
bool * m_buttonInput;
};
#endif

View file

@ -0,0 +1,22 @@
#ifndef MOVE_UP_COMMAND_H
#define MOVE_UP_COMMAND_H
#include "GameCommand.h"
#include <iostream>
#include <memory>
#include <SDL3/SDL.h>
#include "../Components/MoveComponent.h"
class MoveUpCommand : public GameCommand
{
public:
MoveUpCommand(SDL_FPoint & directionInput, bool & buttonInput) : m_directionInput(&directionInput), m_buttonInput(&buttonInput) {};
~MoveUpCommand() {};
void Down() override { m_directionInput->y -= 1; *m_buttonInput = true;}
void Up() override { m_directionInput->y += 1; *m_buttonInput = true;}
private:
SDL_FPoint * m_directionInput;
bool * m_buttonInput;
};
#endif

View file

@ -0,0 +1,20 @@
#ifndef MOVE_X_COMMAND_H
#define MOVE_X_COMMAND_H
#include "AxisCommand.h"
#include <SDL3/SDL.h>
class MoveXCommand : public AxisCommand
{
public:
MoveXCommand(SDL_FPoint & directionInput) : m_directionInput(&directionInput){};
~MoveXCommand() {};
void Execute(float value) override { m_directionInput->x = value;}
private:
SDL_FPoint * m_directionInput;
};
#endif

View file

@ -0,0 +1,20 @@
#ifndef MOVE_Y_COMMAND_H
#define MOVE_Y_COMMAND_H
#include "AxisCommand.h"
#include <SDL3/SDL.h>
class MoveYCommand : public AxisCommand
{
public:
MoveYCommand(SDL_FPoint & directionInput) : m_directionInput(&directionInput){};
~MoveYCommand() {};
void Execute(float value) override { m_directionInput->y = value;}
private:
SDL_FPoint * m_directionInput;
};
#endif

View file

@ -0,0 +1,22 @@
#ifndef SKILL_1_COMMAND_H
#define SKILL_1_COMMAND_H
class Skill1Command
{
private:
/* data */
public:
Skill1Command(/* args */);
~Skill1Command();
};
Skill1Command::Skill1Command(/* args */)
{
}
Skill1Command::~Skill1Command()
{
}
#endif