[Added] Start of player class, start of collision detection
This commit is contained in:
+17
-2
@@ -5,6 +5,9 @@
|
||||
#include "entities/Background.h"
|
||||
#include "services/StateService.h"
|
||||
#include "services/AudioService.h"
|
||||
#include "services/MapService.h"
|
||||
#include "services/InputService.h"
|
||||
#include "entities/Player.h"
|
||||
|
||||
class Game
|
||||
{
|
||||
@@ -24,6 +27,7 @@ public:
|
||||
wrappers.push_back(wrapper3);
|
||||
this->background = Background(wrappers);
|
||||
this->map = Map();
|
||||
MapService::getInstance().setMap(this->map);
|
||||
|
||||
Vector2 screenSize = StateService::getInstance().getScreenSize();
|
||||
Camera2D camera = {0};
|
||||
@@ -33,6 +37,11 @@ public:
|
||||
camera.zoom = 1.0f;
|
||||
this->camera = camera;
|
||||
|
||||
this->player = Player();
|
||||
this->player.getTexture().setPosition({200,350});
|
||||
|
||||
InputService::getInstance().setKeysToWatch({KEY_SPACE, KEY_A, KEY_D}, {MOUSE_BUTTON_LEFT});
|
||||
|
||||
AudioService::getInstance().setMusic(EMusic::GAME);
|
||||
AudioService::getInstance().playMusic();
|
||||
}
|
||||
@@ -42,7 +51,12 @@ public:
|
||||
|
||||
void logic()
|
||||
{
|
||||
this->camera.offset.x -= 1.5;
|
||||
// this->camera.offset.x -= 1.5;
|
||||
this->player.logic();
|
||||
if(this->player.getTexture().getPosition().x > (StateService::getInstance().getScreenSize().x / 2.0f)) {
|
||||
this->camera.offset = {(StateService::getInstance().getScreenSize().x / 2.0f) +((StateService::getInstance().getScreenSize().x / 2.0f) - this->player.getTexture().getPosition().x), StateService::getInstance().getScreenSize().y / 2.0f};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void draw()
|
||||
@@ -52,6 +66,7 @@ public:
|
||||
|
||||
this->background.draw();
|
||||
this->map.draw();
|
||||
this->player.draw();
|
||||
|
||||
EndMode2D();
|
||||
EndDrawing();
|
||||
@@ -61,7 +76,7 @@ private:
|
||||
Camera2D camera;
|
||||
Background background;
|
||||
Map map;
|
||||
// Player player
|
||||
Player player;
|
||||
// std::vector<Enemy> enemies
|
||||
// std::vector<Create> crates
|
||||
// std::vector<PBullet> playerBullets
|
||||
|
||||
Reference in New Issue
Block a user