[Updated] Code for use with WASM, [TODO] Make enemy gun follow player, spawn bullets from tip of the barrel
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "entities/TextureWrapper.h"
|
||||
#include "entities/Vector2i.h"
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
|
||||
class Enemy
|
||||
{
|
||||
@@ -47,7 +48,7 @@ public:
|
||||
return this->texture;
|
||||
}
|
||||
|
||||
u_int8_t getHealth()
|
||||
uint8_t getHealth()
|
||||
{
|
||||
return this->health;
|
||||
}
|
||||
@@ -61,8 +62,8 @@ private:
|
||||
TextureWrapper texture;
|
||||
TextureWrapper gunLeft;
|
||||
TextureWrapper gunRight;
|
||||
u_int8_t health;
|
||||
u_int8_t maxHealth = 5;
|
||||
uint8_t health;
|
||||
uint8_t maxHealth = 5;
|
||||
Vector2 velocity = {0, 0};
|
||||
float spottingRange = 300; // From how far away enemies can spot the player
|
||||
float gravity = 0.6f;
|
||||
|
||||
@@ -20,10 +20,10 @@ public:
|
||||
|
||||
void logic()
|
||||
{
|
||||
if (touched)
|
||||
{
|
||||
StateService::getInstance().setScreen(EScreen::VICTORY);
|
||||
}
|
||||
// if (touched)
|
||||
// {
|
||||
// // StateService::getInstance().setScreen(EScreen::VICTORY);
|
||||
// }
|
||||
}
|
||||
|
||||
void draw()
|
||||
|
||||
+12
-15
@@ -66,7 +66,7 @@ public:
|
||||
|
||||
void logic()
|
||||
{
|
||||
this->crosshair.setPosition(GetMousePosition());
|
||||
this->crosshair.setPosition(InputService::getInstance().getMousePos());
|
||||
|
||||
if (GameService::getInstance().isPaused())
|
||||
{
|
||||
@@ -96,6 +96,9 @@ public:
|
||||
{
|
||||
GameService::getInstance().getCamera().offset = {(StateService::getInstance().getScreenSize().x / 2.0f) + ((StateService::getInstance().getScreenSize().x / 2.0f) - player.getTexture().getPosition().x), StateService::getInstance().getScreenSize().y / 2.0f};
|
||||
}
|
||||
if(player.isFinishReached()) {
|
||||
StateService::getInstance().setScreen(EScreen::VICTORY);
|
||||
}
|
||||
}
|
||||
|
||||
void draw()
|
||||
@@ -113,6 +116,7 @@ public:
|
||||
|
||||
EndMode2D();
|
||||
|
||||
drawHud();
|
||||
if (GameService::getInstance().isPaused())
|
||||
{
|
||||
drawPaused();
|
||||
@@ -120,9 +124,9 @@ public:
|
||||
else if (GameService::getInstance().isGameOver())
|
||||
{
|
||||
drawGameOver();
|
||||
} else {
|
||||
drawCrosshair();
|
||||
}
|
||||
drawHud();
|
||||
drawCrosshair();
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
@@ -184,7 +188,7 @@ private:
|
||||
const int SPACE_PER_ITEM = TOTAL_SPACE / AMNT_OF_BUTTONS;
|
||||
for (int i = 0; i < AMNT_OF_BUTTONS; i++)
|
||||
{
|
||||
Text txt = Text("Play Again", EFont::SANSATION, 30, 0, GRAY);
|
||||
Text txt = Text("Play Again", EFont::SANSATION, 30, 0, BLACK);
|
||||
gameOverScreenButtons.push_back(txt);
|
||||
}
|
||||
gameOverScreenButtons[0].setColor(WHITE);
|
||||
@@ -229,7 +233,7 @@ private:
|
||||
{
|
||||
if (InputService::getInstance().isKeyPressed(KEY_D) || InputService::getInstance().isKeyPressed(KEY_A))
|
||||
{
|
||||
gameOverScreenButtons[hoveredGameOverScreenButton].setColor(GRAY);
|
||||
gameOverScreenButtons[hoveredGameOverScreenButton].setColor(BLACK);
|
||||
/** Move up or down depending on the pressed button. +4 is used so that -1 becomes 3 (the last button) */
|
||||
hoveredGameOverScreenButton = ((hoveredGameOverScreenButton - (InputService::getInstance().isKeyPressed(KEY_D) ? -1 : 1)) + gameOverScreenButtons.size()) % gameOverScreenButtons.size();
|
||||
gameOverScreenButtons[hoveredGameOverScreenButton].setColor(WHITE);
|
||||
@@ -254,7 +258,7 @@ private:
|
||||
void drawPaused()
|
||||
{
|
||||
// 100, 100, 255, 60
|
||||
DrawRectangle(0, 0, StateService::getInstance().getScreenSize().x, StateService::getInstance().getScreenSize().y, {0, 0, 255, 100});
|
||||
DrawRectangle(0, 0, StateService::getInstance().getScreenSize().x, StateService::getInstance().getScreenSize().y, {0, 0, 0, 200});
|
||||
if (pauseScreenButtons.size() > 0)
|
||||
{
|
||||
for (int i = 0; i < pauseScreenButtons.size(); i++)
|
||||
@@ -266,7 +270,7 @@ private:
|
||||
|
||||
void drawGameOver()
|
||||
{
|
||||
DrawRectangle(0, 0, StateService::getInstance().getScreenSize().x, StateService::getInstance().getScreenSize().y, {255, 0, 0, 100});
|
||||
DrawRectangle(0, 0, StateService::getInstance().getScreenSize().x, StateService::getInstance().getScreenSize().y, {100, 0, 0, 200});
|
||||
|
||||
gameOverText.draw();
|
||||
|
||||
@@ -280,17 +284,10 @@ private:
|
||||
{
|
||||
DrawTextureEx(
|
||||
this->crosshair.getTexture(),
|
||||
{GetMousePosition().x - this->crosshair.getSize().x / 2.0f, GetMousePosition().y - this->crosshair.getSize().y / 2.0f},
|
||||
{InputService::getInstance().getMousePos().x - this->crosshair.getSize().x / 2.0f, InputService::getInstance().getMousePos().y - this->crosshair.getSize().y / 2.0f},
|
||||
0,
|
||||
1.2f,
|
||||
RED);
|
||||
// DrawTexturePro(
|
||||
// this->crosshair.getTexture(),
|
||||
// this->crosshair.getSourceRect(),
|
||||
// {GetMousePosition().x, GetMousePosition().y, GetMousePosition().x+this->crosshair.getSize().x, GetMousePosition().y+this->crosshair.getSize().y},
|
||||
// {this->crosshair.getSize().x/2.0f, this->crosshair.getSize().y/2.0f},
|
||||
// 0,
|
||||
// WHITE);
|
||||
}
|
||||
|
||||
void drawHud()
|
||||
|
||||
@@ -81,6 +81,10 @@ public:
|
||||
this->health = std::max(health - damage, 0);
|
||||
}
|
||||
|
||||
bool isFinishReached() {
|
||||
return this->finishReached;
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
TextureWrapper texture;
|
||||
@@ -113,6 +117,7 @@ private:
|
||||
uint8_t health; // Current health of the player
|
||||
uint8_t max_health = 10; // Max health of the player
|
||||
bool gainedPowerup = false;
|
||||
bool finishReached = false;
|
||||
|
||||
void applyGravity();
|
||||
void movement();
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "raylib.h"
|
||||
#include "services/AssetService.h"
|
||||
#include "entities/TextureWrapper.h"
|
||||
#include <cstdint>
|
||||
|
||||
class Powerup {
|
||||
public:
|
||||
@@ -40,8 +41,8 @@ class Powerup {
|
||||
bool pickedUp = false; // When the player has picked up the pack
|
||||
float animationDelay = 0.08f; // How long to wait in between animation frames (in seconds)
|
||||
double lastFrame; // Time since the last frame
|
||||
u_int8_t currentFrame = 0; // Current frame of the animation
|
||||
u_int8_t amountOfFrames = 8; // Total amount of animation frames
|
||||
uint8_t currentFrame = 0; // Current frame of the animation
|
||||
uint8_t amountOfFrames = 8; // Total amount of animation frames
|
||||
|
||||
void animate() {
|
||||
if(GetTime() - lastFrame > animationDelay) {
|
||||
|
||||
+37
-31
@@ -3,47 +3,53 @@
|
||||
|
||||
#include "raylib.h"
|
||||
#include "enums/EFont.h"
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include "services/AssetService.h"
|
||||
#include <string>
|
||||
|
||||
class Text {
|
||||
public:
|
||||
Text(){}
|
||||
Text(std::string text, EFont font, int fontSize = 30, int spacing = 0, Color color = WHITE, Vector2 position = {100,100});
|
||||
~Text(){}
|
||||
class Text
|
||||
{
|
||||
public:
|
||||
Text() {}
|
||||
Text(std::string text, EFont font, int fontSize = 30, int spacing = 0, Color color = WHITE, Vector2 position = {100, 100});
|
||||
~Text() {
|
||||
}
|
||||
|
||||
Vector2 getDimensions();
|
||||
Vector2 getDimensions();
|
||||
|
||||
void setPosition(Vector2 position) {
|
||||
this->position = position;
|
||||
}
|
||||
void setPosition(Vector2 position)
|
||||
{
|
||||
this->position = position;
|
||||
}
|
||||
|
||||
void setColor(Color color) {
|
||||
this->color = color;
|
||||
}
|
||||
void setColor(Color color)
|
||||
{
|
||||
this->color = color;
|
||||
}
|
||||
|
||||
void setText(std::string text) {
|
||||
this->text = text;
|
||||
}
|
||||
void setText(std::string text)
|
||||
{
|
||||
this->text = text;
|
||||
}
|
||||
|
||||
Vector2 getPosition() {
|
||||
return position;
|
||||
}
|
||||
Vector2 getPosition()
|
||||
{
|
||||
return position;
|
||||
}
|
||||
|
||||
std::string getText() {
|
||||
return this->text;
|
||||
}
|
||||
std::string getText()
|
||||
{
|
||||
return this->text;
|
||||
}
|
||||
|
||||
void draw();
|
||||
void draw();
|
||||
|
||||
private:
|
||||
std::string text;
|
||||
Font font;
|
||||
int fontSize;
|
||||
int spacing;
|
||||
Color color;
|
||||
Vector2 position;
|
||||
private:
|
||||
std::string text;
|
||||
Font font;
|
||||
int fontSize;
|
||||
int spacing;
|
||||
Color color;
|
||||
Vector2 position;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -5,7 +5,8 @@ class Screen
|
||||
{
|
||||
public:
|
||||
Screen(){}
|
||||
~Screen() {}
|
||||
~Screen() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute all logic for this frame
|
||||
|
||||
@@ -14,6 +14,8 @@ class VictoryScreen : public Screen
|
||||
|
||||
public:
|
||||
VictoryScreen();
|
||||
~VictoryScreen() {
|
||||
}
|
||||
void logic() override;
|
||||
void draw() override;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "raylib.h"
|
||||
#include "services/Service.h"
|
||||
#include "services/AssetService.h"
|
||||
#include "entities/Bullet.h"
|
||||
#include "entities/PBullet.h"
|
||||
#include "entities/EBullet.h"
|
||||
#include <optional>
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "raylib.h"
|
||||
#include "services/Service.h"
|
||||
#include "services/MapService.h"
|
||||
#include "entities/Vector2i.h"
|
||||
#include "entities/Crate.h"
|
||||
#include "entities/Jelly.h"
|
||||
@@ -94,198 +93,22 @@ private:
|
||||
std::vector<Powerup> powerUps;
|
||||
Flag flag;
|
||||
|
||||
void initCrates()
|
||||
{
|
||||
crates.clear();
|
||||
int tileSize = MapService::getInstance().getMap().getTileSize();
|
||||
for (int i = 0; i < amountOfCrates; i++)
|
||||
{
|
||||
crates.push_back(Crate());
|
||||
}
|
||||
crates[0].getObject().setPosition({38.0f * tileSize, 9.0f * tileSize});
|
||||
crates[1].getObject().setPosition({41.0f * tileSize, 5.0f * tileSize});
|
||||
crates[2].getObject().setPosition({68.0f * tileSize, 4.0f * tileSize});
|
||||
|
||||
for (int i = 0; i < crates.size(); i++)
|
||||
{
|
||||
Vector2i crateTilePos = Vector2i(crates[i].getObject().getPosition().x / tileSize, crates[i].getObject().getPosition().y / tileSize);
|
||||
MapService::getInstance().getMap().updateColmapTile(crateTilePos, true);
|
||||
}
|
||||
}
|
||||
|
||||
void initJellies()
|
||||
{
|
||||
jellies.clear();
|
||||
}
|
||||
|
||||
void initAmmoPacks()
|
||||
{
|
||||
ammoPacks.clear();
|
||||
int tileSize = MapService::getInstance().getMap().getTileSize();
|
||||
for (int i = 0; i < amountOfAmmoPacks; i++)
|
||||
{
|
||||
ammoPacks.push_back(AmmoPack());
|
||||
}
|
||||
ammoPacks[0].getObject().setPosition({32.0f * tileSize, 9.0f * tileSize});
|
||||
ammoPacks[1].getObject().setPosition({48.0f * tileSize, 5.0f * tileSize});
|
||||
ammoPacks[2].getObject().setPosition({88.0f * tileSize, 9.0f * tileSize});
|
||||
ammoPacks[3].getObject().setPosition({105.0f * tileSize, 15.0f * tileSize});
|
||||
}
|
||||
|
||||
void initHealthPacks()
|
||||
{
|
||||
healthPacks.clear();
|
||||
int tileSize = MapService::getInstance().getMap().getTileSize();
|
||||
for (int i = 0; i < amountOfHealthPacks; i++)
|
||||
{
|
||||
healthPacks.push_back(HealthPack());
|
||||
}
|
||||
healthPacks[0].getObject().setPosition({28.0f * tileSize, 10.0f * tileSize});
|
||||
healthPacks[1].getObject().setPosition({64.0f * tileSize, 6.0f * tileSize});
|
||||
healthPacks[2].getObject().setPosition({118.0f * tileSize, 11.0f * tileSize});
|
||||
healthPacks[3].getObject().setPosition({74.0f * tileSize, 8.0f * tileSize});
|
||||
}
|
||||
|
||||
void initPowerups()
|
||||
{
|
||||
powerUps.clear();
|
||||
int tileSize = MapService::getInstance().getMap().getTileSize();
|
||||
for (int i = 0; i < amountOfPowerups; i++)
|
||||
{
|
||||
powerUps.push_back(Powerup());
|
||||
}
|
||||
powerUps[0].getObject().setPosition({41.0f * tileSize+8, 10.0f * tileSize-25});
|
||||
}
|
||||
|
||||
void initFlag() {
|
||||
int tileSize = MapService::getInstance().getMap().getTileSize();
|
||||
this->flag = Flag({118.0f*tileSize-tileSize/2.0f, 3.0f * tileSize-8});
|
||||
}
|
||||
|
||||
void crateLogic()
|
||||
{
|
||||
for (auto it = crates.begin(); it != crates.end();)
|
||||
{
|
||||
auto &crate = *it;
|
||||
/**
|
||||
* If the crate has been hit:
|
||||
* 1. Create a Jelly on the location of the crate
|
||||
* 2. Remove the collision tile from the collision map
|
||||
* 3. Remove the crate
|
||||
*/
|
||||
if (crate.hasBeenHit())
|
||||
{
|
||||
Vector2 pos = crate.getObject().getPosition();
|
||||
|
||||
jellies.push_back(Jelly(pos));
|
||||
|
||||
Vector2i tilePos = Vector2i(pos.x / MapService::getInstance().getMap().getTileSize(), pos.y / MapService::getInstance().getMap().getTileSize());
|
||||
MapService::getInstance().getMap().updateColmapTile(tilePos, false);
|
||||
it = crates.erase(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void jellyLogic()
|
||||
{
|
||||
for (int i = 0; i < jellies.size(); i++)
|
||||
{
|
||||
jellies[i].logic();
|
||||
}
|
||||
}
|
||||
|
||||
void ammoPackLogic()
|
||||
{
|
||||
for (auto it = ammoPacks.begin(); it != ammoPacks.end();)
|
||||
{
|
||||
auto &ammoPack = *it;
|
||||
if (ammoPack.hasBeenPickedUp())
|
||||
{
|
||||
it = ammoPacks.erase(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void healthPackLogic()
|
||||
{
|
||||
for (auto it = healthPacks.begin(); it != healthPacks.end();)
|
||||
{
|
||||
auto &healthPack = *it;
|
||||
if (healthPack.hasBeenPickedUp())
|
||||
{
|
||||
it = healthPacks.erase(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void powerupLogic()
|
||||
{
|
||||
for (auto it = powerUps.begin(); it != powerUps.end();)
|
||||
{
|
||||
auto &powerUp = *it;
|
||||
if (powerUp.hasBeenPickedUp())
|
||||
{
|
||||
it = powerUps.erase(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
powerUp.logic();
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void drawCrates()
|
||||
{
|
||||
for (int i = 0; i < crates.size(); i++)
|
||||
{
|
||||
crates[i].draw();
|
||||
}
|
||||
}
|
||||
|
||||
void drawJellies()
|
||||
{
|
||||
for (int i = 0; i < jellies.size(); i++)
|
||||
{
|
||||
jellies[i].draw();
|
||||
}
|
||||
}
|
||||
|
||||
void drawAmmoPacks()
|
||||
{
|
||||
for (int i = 0; i < ammoPacks.size(); i++)
|
||||
{
|
||||
ammoPacks[i].draw();
|
||||
}
|
||||
}
|
||||
|
||||
void drawHealthpacks()
|
||||
{
|
||||
for (int i = 0; i < healthPacks.size(); i++)
|
||||
{
|
||||
healthPacks[i].draw();
|
||||
}
|
||||
}
|
||||
|
||||
void drawPowerups()
|
||||
{
|
||||
for (int i = 0; i < powerUps.size(); i++)
|
||||
{
|
||||
powerUps[i].draw();
|
||||
}
|
||||
}
|
||||
void initCrates();
|
||||
void initJellies();
|
||||
void initAmmoPacks();
|
||||
void initHealthPacks();
|
||||
void initPowerups();
|
||||
void initFlag();
|
||||
void crateLogic();
|
||||
void jellyLogic();
|
||||
void ammoPackLogic();
|
||||
void healthPackLogic();
|
||||
void powerupLogic();
|
||||
void drawCrates();
|
||||
void drawJellies();
|
||||
void drawAmmoPacks();
|
||||
void drawHealthpacks();
|
||||
void drawPowerups();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -3,61 +3,16 @@
|
||||
|
||||
#include "raylib.h"
|
||||
#include "services/Service.h"
|
||||
#include "services/AssetService.h"
|
||||
#include "entities/Enemy.h"
|
||||
#include <optional>
|
||||
|
||||
class EnemyService : public Service<EnemyService>
|
||||
{
|
||||
public:
|
||||
void initEnemies()
|
||||
{
|
||||
this->enemies.clear();
|
||||
const int AMNT_OF_ENEMIES = 8;
|
||||
int tileSize = MapService::getInstance().getMap().getTileSize();
|
||||
for (int i = 0; i < AMNT_OF_ENEMIES; i++)
|
||||
{
|
||||
enemies.push_back(Enemy());
|
||||
}
|
||||
this->enemies[0].getObject().setPosition({31.0f * tileSize, 15.0f * tileSize});
|
||||
this->enemies[1].getObject().setPosition({51.0f * tileSize, 10.0f * tileSize});
|
||||
this->enemies[2].getObject().setPosition({56.0f * tileSize, 5.0f * tileSize});
|
||||
this->enemies[3].getObject().setPosition({78.0f * tileSize, 10.0f * tileSize});
|
||||
this->enemies[4].getObject().setPosition({82.0f * tileSize, 15.0f * tileSize});
|
||||
this->enemies[5].getObject().setPosition({88.0f * tileSize, 4.0f * tileSize});
|
||||
this->enemies[6].getObject().setPosition({98.0f * tileSize, 11.0f * tileSize});
|
||||
this->enemies[7].getObject().setPosition({103.0f * tileSize, 15.0f * tileSize});
|
||||
}
|
||||
|
||||
void enemyLogic()
|
||||
{
|
||||
for (auto it = enemies.begin(); it != enemies.end();)
|
||||
{
|
||||
auto &enemy = *it;
|
||||
if (enemy.getObject().getPosition().y < 0)
|
||||
{
|
||||
it = enemies.erase(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
enemy.logic();
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void drawEnemies()
|
||||
{
|
||||
for (int i = 0; i < enemies.size(); i++)
|
||||
{
|
||||
enemies[i].draw();
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<Enemy> &getEnemies()
|
||||
{
|
||||
return this->enemies;
|
||||
}
|
||||
void initEnemies();
|
||||
void enemyLogic();
|
||||
void drawEnemies();
|
||||
std::vector<Enemy> &getEnemies();
|
||||
|
||||
protected:
|
||||
private:
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "raylib.h"
|
||||
#include "services/Service.h"
|
||||
#include "services/AudioService.h"
|
||||
#include "services/InputService.h"
|
||||
#include <vector>
|
||||
#include <list>
|
||||
|
||||
@@ -49,7 +50,8 @@ public:
|
||||
|
||||
Vector2 getMouseWorldPos()
|
||||
{
|
||||
Vector2 mouseWorldPos = {GetMousePosition().x + camera.target.x - camera.offset.x, GetMousePosition().y};
|
||||
Vector2 mouseWorldPos = {InputService::getInstance().getMousePos().x + camera.target.x - camera.offset.x,
|
||||
InputService::getInstance().getMousePos().y};
|
||||
return mouseWorldPos;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifndef INPUT_SERVICE_H
|
||||
#define INPUT_SERVICE_H
|
||||
|
||||
#include "Service.h"
|
||||
#include "raylib.h"
|
||||
#include "Service.h"
|
||||
#include <vector>
|
||||
#include <unordered_set>
|
||||
#include <unordered_map>
|
||||
@@ -69,6 +69,14 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void checkMousePos() {
|
||||
this->mousePosition = GetMousePosition();
|
||||
}
|
||||
|
||||
Vector2 getMousePos() {
|
||||
return this->mousePosition;
|
||||
}
|
||||
|
||||
bool isKeyPressed(KeyboardKey key)
|
||||
{
|
||||
return keysPressed[key];
|
||||
@@ -88,6 +96,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
Vector2 mousePosition {0,0};
|
||||
std::unordered_set<KeyboardKey> watchedKeys;
|
||||
std::unordered_map<KeyboardKey, bool> keysPressed;
|
||||
std::unordered_map<KeyboardKey, bool> keysDown;
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
#ifndef STATE_SERVICE_H
|
||||
#define STATE_SERVICE_H
|
||||
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include "services/Service.h"
|
||||
#include "screens/Screen.h"
|
||||
#include "enums/EScreen.h"
|
||||
#include "raylib.h"
|
||||
#include "enums/EScreen.h"
|
||||
#include "services/Service.h"
|
||||
#include "services/InputService.h"
|
||||
#include "screens/Screen.h"
|
||||
#include <memory>
|
||||
|
||||
#if defined(PLATFORM_WEB)
|
||||
#include <emscripten/emscripten.h>
|
||||
#endif
|
||||
// #include <emscripten/html5.h>
|
||||
|
||||
/**
|
||||
* Handles switching between screens
|
||||
@@ -34,14 +35,10 @@ public:
|
||||
void startGame();
|
||||
static void staticStep()
|
||||
{
|
||||
if (IsKeyPressed(KEY_ENTER) || IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
|
||||
{
|
||||
std::cout << "Input!" << std::endl;
|
||||
}
|
||||
// Access the singleton instance and call step
|
||||
getInstance().step();
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
std::unique_ptr<Screen> currentScreen;
|
||||
bool gameRunning = true;
|
||||
@@ -52,6 +49,7 @@ private:
|
||||
*/
|
||||
void step();
|
||||
void handleMusic();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user