[Added] Tutorial Screen, Start of the Game Screen
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include <unordered_map>
|
||||
#include "EFont.h"
|
||||
#include "EMusic.h"
|
||||
#include "EBackground.h"
|
||||
#include "Service.h"
|
||||
|
||||
class AssetService: public Service<AssetService>
|
||||
@@ -19,6 +20,7 @@ private:
|
||||
std::unordered_map<EFont, std::string> fonts;
|
||||
std::vector<Sound> sounds;
|
||||
std::unordered_map<EMusic, Music> music;
|
||||
std::unordered_map<EBackground, Texture2D> backgrounds;
|
||||
|
||||
void setAssets();
|
||||
|
||||
@@ -35,6 +37,10 @@ public:
|
||||
Music getMusic(EMusic music) {
|
||||
return this->music[music];
|
||||
}
|
||||
Texture2D getBackground(EBackground background){
|
||||
return this->backgrounds[background];
|
||||
}
|
||||
Texture2D loadTexture(std::string filename);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -9,13 +9,10 @@
|
||||
class AudioService : public Service<AudioService>
|
||||
{
|
||||
private:
|
||||
/** Friend to allow access to the destructor */
|
||||
// friend class Service<AudioService>;
|
||||
std::optional<Music> music;
|
||||
EMusic currentTrack;
|
||||
EMusic currentTrack = EMusic::NONE;
|
||||
|
||||
protected:
|
||||
// ~AudioService();
|
||||
|
||||
public:
|
||||
void setMusic(EMusic music);
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef BACKGROUND_H
|
||||
#define BACKGROUND_H
|
||||
|
||||
#include "raylib.h"
|
||||
#include "EBackground.h"
|
||||
#include <vector>
|
||||
|
||||
class Background {
|
||||
private:
|
||||
Vector2 position;
|
||||
std::vector<Texture2D> textures;
|
||||
protected:
|
||||
public:
|
||||
Background(EBackground background);
|
||||
Background(std::vector<EBackground> backgrounds);
|
||||
~Background(){}
|
||||
Vector2 getPosition();
|
||||
void updatePosition(Vector2 deltaPos);
|
||||
void setPosition(Vector2 position);
|
||||
void draw();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,13 @@
|
||||
#ifndef EBACKGROUND_H
|
||||
#define EBACKGROUND_H
|
||||
|
||||
enum class EBackground {
|
||||
TUTORIAL,
|
||||
GAME1,
|
||||
GAME2,
|
||||
GAME3,
|
||||
VICTORY
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef GAME_SCREEN_H
|
||||
#define GAME_SCREEN_H
|
||||
|
||||
#include "Screen.h"
|
||||
|
||||
class GameScreen: public Screen {
|
||||
|
||||
private:
|
||||
protected:
|
||||
public:
|
||||
GameScreen();
|
||||
void logic() override;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -2,8 +2,6 @@
|
||||
#define MAIN_SCREEN_H
|
||||
|
||||
#include "Screen.h"
|
||||
#include "raylib.h"
|
||||
#include <string>
|
||||
|
||||
class MainScreen : public Screen {
|
||||
private:
|
||||
@@ -11,10 +9,10 @@ private:
|
||||
|
||||
void mouseLogic();
|
||||
void keyboardLogic();
|
||||
void clickLogic();
|
||||
|
||||
public:
|
||||
MainScreen();
|
||||
~MainScreen();
|
||||
|
||||
void logic() override;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#ifndef MAP_H
|
||||
#define MAP_H
|
||||
|
||||
#include <vector>
|
||||
#include "raylib.h"
|
||||
|
||||
/**
|
||||
* Holds the collision and texture maps for the game world
|
||||
*/
|
||||
class Map
|
||||
{
|
||||
public:
|
||||
Map();
|
||||
~Map() {}
|
||||
|
||||
void draw();
|
||||
|
||||
private:
|
||||
/** Holds the number for every single tile, which refers to a certain sprite in the tileset */
|
||||
std::vector<std::vector<Vector2>> map;
|
||||
/** Holds 1s (collision) and 0s (no collision) for every tile */
|
||||
std::vector<std::vector<int>> colMap;
|
||||
|
||||
float tileSize = 32;
|
||||
|
||||
Texture2D tileset;
|
||||
|
||||
void loadMap();
|
||||
void loadColMap(){}
|
||||
void loadTileset();
|
||||
};
|
||||
|
||||
#endif
|
||||
+9
-1
@@ -3,15 +3,23 @@
|
||||
|
||||
#include <vector>
|
||||
#include "Text.h"
|
||||
#include "raylib.h"
|
||||
#include <optional>
|
||||
#include "Background.h"
|
||||
#include "Map.h"
|
||||
|
||||
class Screen {
|
||||
private:
|
||||
|
||||
protected:
|
||||
// std::optional<Map> map;
|
||||
std::optional<Camera2D> camera;
|
||||
std::optional<Map> map;
|
||||
std::optional<Background> background;
|
||||
std::vector<Text> text;
|
||||
|
||||
public:
|
||||
Screen(){}
|
||||
Screen();
|
||||
~Screen(){}
|
||||
|
||||
/**
|
||||
|
||||
+11
-1
@@ -11,6 +11,9 @@
|
||||
#include <emscripten/emscripten.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Handles switching between screens
|
||||
*/
|
||||
class StateService : public Service<StateService>
|
||||
{
|
||||
private:
|
||||
@@ -18,6 +21,8 @@ private:
|
||||
|
||||
bool gameRunning = true;
|
||||
|
||||
Vector2 screenSize;
|
||||
|
||||
/**
|
||||
* One step of the gameloop
|
||||
*/
|
||||
@@ -26,7 +31,12 @@ private:
|
||||
void handleMusic();
|
||||
|
||||
public:
|
||||
|
||||
Vector2 getScreenSize(){
|
||||
return screenSize;
|
||||
}
|
||||
void setScreenSize(Vector2 screenSize) {
|
||||
this->screenSize = screenSize;
|
||||
}
|
||||
void setScreen(EScreen screen);
|
||||
Screen *getScreen();
|
||||
/**
|
||||
|
||||
+1
-2
@@ -18,7 +18,7 @@ class Text {
|
||||
|
||||
public:
|
||||
Text(std::string text, EFont font, int fontSize = 30, int spacing = 0, Color color = WHITE, Vector2 position = {100,100});
|
||||
~Text();
|
||||
~Text(){}
|
||||
|
||||
Vector2 getDimensions();
|
||||
|
||||
@@ -42,7 +42,6 @@ class Text {
|
||||
return this->text;
|
||||
}
|
||||
|
||||
|
||||
void draw();
|
||||
};
|
||||
|
||||
|
||||
@@ -3,22 +3,15 @@
|
||||
|
||||
#include "Screen.h"
|
||||
#include "raylib.h"
|
||||
#include "Text.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class TitleScreen : public Screen {
|
||||
private:
|
||||
Music bg;
|
||||
// std::vector<Text> text;
|
||||
|
||||
public:
|
||||
TitleScreen();
|
||||
~TitleScreen();
|
||||
|
||||
// void step() override;
|
||||
void logic() override;
|
||||
// void draw() override;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef TUTORIAL_SCREEN_H
|
||||
#define TUTORIAL_SCREEN_H
|
||||
|
||||
#include "Screen.h"
|
||||
|
||||
class TutorialScreen : public Screen {
|
||||
private:
|
||||
protected:
|
||||
public:
|
||||
TutorialScreen();
|
||||
|
||||
void logic() override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user