igra
This commit is contained in:
@@ -7,16 +7,24 @@
|
||||
#include <game/gamemanager.hpp>
|
||||
#include <game/agame/enemy.hpp>
|
||||
#include <game/agame/trash.hpp>
|
||||
#include <game/agame/friendly.hpp>
|
||||
|
||||
namespace Game::AGame {
|
||||
GAME_ENTITY(Background)
|
||||
public:
|
||||
void render(Game::Renderer::Renderer* renderer, Game::Renderer::RendererConfig config) override;
|
||||
void onWindowResized(int newWidth, int newHeight) override;
|
||||
private:
|
||||
float mEnemySpawnTimer = 0.f;
|
||||
float mTimeToSpawn = 5.f;
|
||||
void spawnLevel(int stage);
|
||||
void spawnFriendly(int stage, int count);
|
||||
int mW, mH;
|
||||
int mMaxLevels = 2;
|
||||
float mLandBoundaryX = 0.f;
|
||||
bool mPendingLevelSpawn = false;
|
||||
int mPendingLevelStage = 0;
|
||||
std::shared_ptr<Game::Renderer::Texture> mSeaTex;
|
||||
std::shared_ptr<Game::Renderer::Texture> mEnemyTex;
|
||||
std::shared_ptr<Game::Renderer::Texture> mTrashTex;
|
||||
std::shared_ptr<Game::Renderer::Texture> mFriendlyTex;
|
||||
END_GAME_ENTITY()
|
||||
}
|
||||
@@ -10,5 +10,10 @@ namespace Game::AGame {
|
||||
GAME_ENTITY(Enemy)
|
||||
public:
|
||||
void onCollisionEnter(Object::Entity* other) override;
|
||||
bool hasAdjacentEnemy();
|
||||
private:
|
||||
float mMoveSpeedX = 0.f;
|
||||
float mMoveSpeedY = 0.f;
|
||||
float mDirectionChangeTimer = 0.f;
|
||||
END_GAME_ENTITY()
|
||||
}
|
||||
18
include/game/agame/friendly.hpp
Normal file
18
include/game/agame/friendly.hpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <game/gamemanager.hpp>
|
||||
#include <object/entity.hpp>
|
||||
#include <renderer/texture.hpp>
|
||||
#include <renderer/font.hpp>
|
||||
#include <object/sound.hpp>
|
||||
|
||||
namespace Game::AGame {
|
||||
GAME_ENTITY(Friendly)
|
||||
public:
|
||||
void onCollisionEnter(Object::Entity* other) override;
|
||||
private:
|
||||
float mMoveSpeedX = 0.f;
|
||||
float mMoveSpeedY = 0.f;
|
||||
float mDirectionChangeTimer = 0.f;
|
||||
END_GAME_ENTITY()
|
||||
}
|
||||
14
include/game/agame/hudtext.hpp
Normal file
14
include/game/agame/hudtext.hpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <object/ui/uitext.hpp>
|
||||
|
||||
namespace Game::AGame {
|
||||
class HUDText : public Object::UIText {
|
||||
using Object::UIText::UIText;
|
||||
|
||||
public:
|
||||
~HUDText() override = default;
|
||||
void start() override;
|
||||
void update(float deltaTime) override;
|
||||
};
|
||||
}
|
||||
@@ -7,9 +7,19 @@
|
||||
|
||||
namespace Game::AGame {
|
||||
GAME_ENTITY(Player)
|
||||
private:
|
||||
Object::Sound mSound;
|
||||
float mSpeed = 200.f; // Pixels per second
|
||||
[[maybe_unused]] float mHealth = 100.f;
|
||||
public:
|
||||
void setShipTexture(std::shared_ptr<Game::Renderer::Texture> tex);
|
||||
void setGroundTexture(std::shared_ptr<Game::Renderer::Texture> tex);
|
||||
void respawnRandomSea(float landBoundaryX);
|
||||
bool isShipMode() const { return mIsShipMode; }
|
||||
void onCollisionEnter(Object::Entity* other) override;
|
||||
private:
|
||||
Object::Sound mSound;
|
||||
float mSpeed = 200.f; // Pixels per second
|
||||
[[maybe_unused]] float mHealth = 100.f;
|
||||
std::shared_ptr<Game::Renderer::Texture> mShipTex;
|
||||
std::shared_ptr<Game::Renderer::Texture> mGroundTex;
|
||||
bool mIsShipMode = true;
|
||||
float mShoreMargin = 40.f;
|
||||
END_GAME_ENTITY()
|
||||
}
|
||||
@@ -6,7 +6,13 @@
|
||||
#include <renderer/font.hpp>
|
||||
#include <object/sound.hpp>
|
||||
|
||||
namespace Game::AGame {
|
||||
class Player;
|
||||
}
|
||||
|
||||
namespace Game::AGame {
|
||||
GAME_ENTITY(Trash)
|
||||
public:
|
||||
void onCollisionEnter(Object::Entity* other) override;
|
||||
END_GAME_ENTITY()
|
||||
}
|
||||
Reference in New Issue
Block a user