[Added] Start of player class, start of collision detection
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "enums/EMusic.h"
|
||||
#include "enums/EBackground.h"
|
||||
#include "enums/EMap.h"
|
||||
#include "enums/ESprite.h"
|
||||
#include "services/Service.h"
|
||||
|
||||
class AssetService: public Service<AssetService>
|
||||
@@ -27,6 +28,9 @@ public:
|
||||
std::string getMapUrl(EMap map) {
|
||||
return this->assetDir + this->maps[map];
|
||||
}
|
||||
Texture2D getSprite(ESprite sprite) {
|
||||
return this->sprites[sprite];
|
||||
}
|
||||
|
||||
protected:
|
||||
AssetService();
|
||||
@@ -41,6 +45,7 @@ private:
|
||||
std::unordered_map<EMusic, Music> music;
|
||||
std::unordered_map<EBackground, Texture2D> backgrounds;
|
||||
std::unordered_map<EMap, std::string> maps;
|
||||
std::unordered_map<ESprite, Texture2D> sprites;
|
||||
|
||||
void setAssets();
|
||||
|
||||
|
||||
@@ -20,11 +20,13 @@ public:
|
||||
{
|
||||
this->watchedKeys.clear();
|
||||
this->keysPressed.clear();
|
||||
this->keysDown.clear();
|
||||
|
||||
for (int i = 0; i < keysToWatch.size(); i++)
|
||||
{
|
||||
this->watchedKeys.insert(keysToWatch[i]);
|
||||
this->keysPressed[keysToWatch[i]] = false;
|
||||
this->keysDown[keysToWatch[i]] = false;
|
||||
}
|
||||
|
||||
setMouseButtonsToWatch(mouseButtonsToWatch);
|
||||
@@ -42,10 +44,15 @@ public:
|
||||
for (auto key : watchedKeys)
|
||||
{
|
||||
keysPressed[key] = false;
|
||||
keysDown[key] = false;
|
||||
if (IsKeyPressed(key))
|
||||
{
|
||||
keysPressed[key] = true;
|
||||
}
|
||||
if (IsKeyDown(key))
|
||||
{
|
||||
keysDown[key] = true;
|
||||
}
|
||||
}
|
||||
for (auto button : watchedMouseButtons)
|
||||
{
|
||||
@@ -62,6 +69,10 @@ public:
|
||||
return keysPressed[key];
|
||||
}
|
||||
|
||||
bool isKeyDown(KeyboardKey key) {
|
||||
return keysDown[key];
|
||||
}
|
||||
|
||||
bool isMouseButtonPressed(MouseButton button)
|
||||
{
|
||||
return mouseButtonsPressed[button];
|
||||
@@ -70,6 +81,7 @@ public:
|
||||
private:
|
||||
std::unordered_set<KeyboardKey> watchedKeys;
|
||||
std::unordered_map<KeyboardKey, bool> keysPressed;
|
||||
std::unordered_map<KeyboardKey, bool> keysDown;
|
||||
std::unordered_set<MouseButton> watchedMouseButtons;
|
||||
std::unordered_map<MouseButton, bool> mouseButtonsPressed;
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef MAP_SERVICE_H
|
||||
#define MAP_SERVICE_H
|
||||
|
||||
#include "services/Service.h"
|
||||
#include "entities/Map.h"
|
||||
#include "entities/TextureWrapper.h"
|
||||
|
||||
/**
|
||||
* Allows all rigidbodies to check against the current Map
|
||||
*/
|
||||
class MapService : public Service<MapService>
|
||||
{
|
||||
public:
|
||||
void setMap(Map map)
|
||||
{
|
||||
this->map = Map();
|
||||
}
|
||||
|
||||
Map& getMap() {
|
||||
return this->map;
|
||||
}
|
||||
|
||||
private:
|
||||
Map map;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user