ALOT, titlescreen, sound, enemies
This commit is contained in:
Binary file not shown.
1
TODO
1
TODO
@@ -10,6 +10,7 @@
|
||||
[d] Fix collision
|
||||
[x] Better player spritesheet
|
||||
[x] Animation system
|
||||
[x] Sound
|
||||
[ ] Enemies / AI
|
||||
[ ] Dungeon fixed entity spawning
|
||||
[ ] Enemy AI
|
||||
|
||||
Binary file not shown.
@@ -15,7 +15,7 @@ bool EntityCollide(Entity* entity, std::vector<Tile*>& nearby, int tileSize, Col
|
||||
|
||||
static Logger& _Logger = Logger::getInstance();
|
||||
|
||||
engine->SetDrawTarget(uint8_t(0));
|
||||
engine->SetDrawTarget(1);
|
||||
engine->Clear(olc::BLANK);
|
||||
|
||||
float entityX = static_cast<float>(entity->Coords.x - entity->TrackingCamera->Coords.x);
|
||||
@@ -28,12 +28,12 @@ bool EntityCollide(Entity* entity, std::vector<Tile*>& nearby, int tileSize, Col
|
||||
int entityTop = static_cast<int>(entityY);
|
||||
int entityBottom = static_cast<int>(entityY + entityH);
|
||||
|
||||
if (ShowDebug)
|
||||
if (ShowCollisionDebug)
|
||||
engine->DrawRect(entityX, entityY, entityW, entityH, olc::RED);
|
||||
|
||||
for (auto tile : nearby)
|
||||
{
|
||||
if (ShowDebug)
|
||||
if (ShowCollisionDebug)
|
||||
engine->DrawRect({ static_cast<int>(static_cast<float>((tile->Coords.x * tileSize) - entity->TrackingCamera->Coords.x)), static_cast<int>(static_cast<float>((tile->Coords.y * tileSize) - entity->TrackingCamera->Coords.y)) }, {tileSize, tileSize}, olc::BLUE);
|
||||
|
||||
// return if not collidable
|
||||
@@ -51,7 +51,7 @@ bool EntityCollide(Entity* entity, std::vector<Tile*>& nearby, int tileSize, Col
|
||||
|
||||
bool collision = xOverlaps && yOverlaps;
|
||||
|
||||
if (ShowDebug)
|
||||
if (ShowCollisionDebug)
|
||||
engine->FillRect({static_cast<int>(static_cast<float>((tile->Coords.x * tileSize) - entity->TrackingCamera->Coords.x)), static_cast<int>(static_cast<float>((tile->Coords.y * tileSize) - entity->TrackingCamera->Coords.y))}, {tileSize, tileSize}, collision ? olc::RED : olc::BLUE);
|
||||
|
||||
if (!collision) continue;
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
void PerlinNoise1D(int nCount, float *fSeed, int nOctaves, float fBias, float *fOutput)
|
||||
{
|
||||
// Used 1D Perlin Noise
|
||||
for (int x = 0; x < nCount; x++)
|
||||
{
|
||||
float fNoise = 0.0f;
|
||||
@@ -80,7 +79,21 @@ Dungeon::Dungeon()
|
||||
Player->Type = EEntity::Type::Player;
|
||||
// Relative to player TL corner
|
||||
// not really used ? lol
|
||||
Player->HitBox = new Collider{ 0, 0, 28, 36 } ;
|
||||
Player->HitBox = new Collider{ 0, 0, 28, 36 };
|
||||
|
||||
EnemyRenderable = new olc::Renderable();
|
||||
EnemyRenderable->Load("res/player.png");
|
||||
EnemyAnimator = new olc::AnimatedSprite();
|
||||
EnemyAnimator->mode = olc::AnimatedSprite::SPRITE_MODE::SINGLE;
|
||||
EnemyAnimator->type = olc::AnimatedSprite::SPRITE_TYPE::DECAL;
|
||||
EnemyAnimator->spriteSheet = EnemyRenderable;
|
||||
EnemyAnimator->SetSpriteSize({28, 36});
|
||||
|
||||
EnemyAnimator->AddState("idle", 0.127f, olc::AnimatedSprite::PLAY_MODE::LOOP, std::vector<olc::vi2d>{
|
||||
{28, 0}
|
||||
});
|
||||
EnemyAnimator->SetState("idle");
|
||||
|
||||
|
||||
Player->Renderable = new olc::Renderable();
|
||||
Player->Renderable->Load("res/player.png");
|
||||
@@ -90,29 +103,29 @@ Dungeon::Dungeon()
|
||||
Player->Animator->spriteSheet = Player->Renderable;
|
||||
Player->Animator->SetSpriteSize({28, 36});
|
||||
|
||||
Player->Animator->AddState("idle", std::vector<olc::vi2d>{
|
||||
Player->Animator->AddState("idle", 0.127f, olc::AnimatedSprite::PLAY_MODE::LOOP, std::vector<olc::vi2d>{
|
||||
{28, 0}
|
||||
});
|
||||
|
||||
Player->Animator->AddState("north", std::vector<olc::vi2d>{
|
||||
Player->Animator->AddState("north", 0.127f, olc::AnimatedSprite::PLAY_MODE::LOOP, std::vector<olc::vi2d>{
|
||||
{0, 110},
|
||||
{28, 110},
|
||||
{56, 110},
|
||||
{84, 110}
|
||||
});
|
||||
Player->Animator->AddState("east", std::vector<olc::vi2d>{
|
||||
Player->Animator->AddState("east", 0.127f, olc::AnimatedSprite::PLAY_MODE::LOOP, std::vector<olc::vi2d>{
|
||||
{0, 36},
|
||||
{28, 36},
|
||||
{56, 36},
|
||||
{84, 36}
|
||||
});
|
||||
Player->Animator->AddState("south", std::vector<olc::vi2d>{
|
||||
Player->Animator->AddState("south", 0.127f, olc::AnimatedSprite::PLAY_MODE::LOOP, std::vector<olc::vi2d>{
|
||||
{0, 0},
|
||||
{28, 0},
|
||||
{56, 0},
|
||||
{84, 0}
|
||||
});
|
||||
Player->Animator->AddState("west", std::vector<olc::vi2d>{
|
||||
Player->Animator->AddState("west", 0.127f, olc::AnimatedSprite::PLAY_MODE::LOOP, std::vector<olc::vi2d>{
|
||||
{0, 72},
|
||||
{28, 72},
|
||||
{56, 72},
|
||||
@@ -133,6 +146,27 @@ Dungeon::Dungeon()
|
||||
FireOverlay = new olc::Renderable();
|
||||
FireOverlay->Load("res/torch.png");
|
||||
|
||||
SoundBufferFireLighting.loadFromFile("res/fire_start.wav");
|
||||
SoundFireLighting.setBuffer(SoundBufferFireLighting);
|
||||
SoundFireLighting.setLoop(false);
|
||||
SoundFireLighting.setVolume(50.f);
|
||||
|
||||
SoundBufferFire.loadFromFile("res/fire.wav");
|
||||
SoundFire.setBuffer(SoundBufferFire);
|
||||
SoundFire.setLoop(true);
|
||||
SoundFire.setVolume(100.f);
|
||||
|
||||
SoundBufferAmbient.loadFromFile("res/ambient.ogg");
|
||||
SoundAmbient.setBuffer(SoundBufferAmbient);
|
||||
SoundAmbient.setLoop(true);
|
||||
SoundAmbient.play();
|
||||
|
||||
SoundBufferFootsteps.loadFromFile("res/run.ogg");
|
||||
SoundFootsteps.setBuffer(SoundBufferFootsteps);
|
||||
SoundFootsteps.setLoop(true);
|
||||
SoundFootsteps.setVolume(20.f);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Dungeon::Generate()
|
||||
@@ -283,11 +317,6 @@ void Dungeon::Generate()
|
||||
}
|
||||
}
|
||||
|
||||
void Dungeon::SpawnEntity(Entity* entity)
|
||||
{
|
||||
Entities[entity->Coords] = entity;
|
||||
}
|
||||
|
||||
void Dungeon::Input(olc::PixelGameEngine* engine, float fTime)
|
||||
{
|
||||
|
||||
@@ -295,30 +324,36 @@ void Dungeon::Input(olc::PixelGameEngine* engine, float fTime)
|
||||
|
||||
static std::string state = "idle";
|
||||
static std::string lastState = "idle";
|
||||
static bool WasMoving = false;
|
||||
bool IsMoving = false;
|
||||
|
||||
if (engine->GetKey(olc::W).bHeld)
|
||||
{
|
||||
Player->Coords.y -= static_cast<float>(TileSize) * (fTime * Player->Speed);
|
||||
if (state != "north")
|
||||
state = "north";
|
||||
IsMoving = true;
|
||||
}
|
||||
if (engine->GetKey(olc::A).bHeld)
|
||||
{
|
||||
Player->Coords.x -= static_cast<float>(TileSize) * (fTime * Player->Speed);
|
||||
if (state != "west")
|
||||
state = "west";
|
||||
IsMoving = true;
|
||||
}
|
||||
if (engine->GetKey(olc::S).bHeld)
|
||||
{
|
||||
Player->Coords.y += static_cast<float>(TileSize) * (fTime * Player->Speed);
|
||||
if (state != "south")
|
||||
state = "south";
|
||||
IsMoving = true;
|
||||
}
|
||||
if (engine->GetKey(olc::D).bHeld)
|
||||
{
|
||||
Player->Coords.x += static_cast<float>(TileSize) * (fTime * Player->Speed);
|
||||
if (state != "east")
|
||||
state = "east";
|
||||
IsMoving = true;
|
||||
}
|
||||
|
||||
if (engine->GetKey(olc::W).bHeld && engine->GetKey(olc::A).bHeld)
|
||||
@@ -327,7 +362,6 @@ void Dungeon::Input(olc::PixelGameEngine* engine, float fTime)
|
||||
Player->Coords.x += static_cast<float>(TileSize) * (fTime * (Player->Speed / 3.0f));
|
||||
if (state != "west")
|
||||
state = "west";
|
||||
|
||||
}
|
||||
if (engine->GetKey(olc::W).bHeld && engine->GetKey(olc::D).bHeld)
|
||||
{
|
||||
@@ -352,8 +386,22 @@ void Dungeon::Input(olc::PixelGameEngine* engine, float fTime)
|
||||
state = "west";
|
||||
}
|
||||
|
||||
if (!WasMoving && IsMoving)
|
||||
{
|
||||
SoundFootsteps.setPlayingOffset(sf::seconds(0.05f));
|
||||
SoundFootsteps.play();
|
||||
}
|
||||
if (WasMoving && !IsMoving)
|
||||
{
|
||||
SoundFootsteps.stop();
|
||||
}
|
||||
WasMoving = IsMoving;
|
||||
|
||||
if (oldCoords == Player->Coords)
|
||||
{
|
||||
state = "idle";
|
||||
SoundFootsteps.pause();
|
||||
}
|
||||
if (state != lastState)
|
||||
Player->Animator->SetState(state);
|
||||
lastState = state;
|
||||
@@ -427,6 +475,31 @@ void Dungeon::Input(olc::PixelGameEngine* engine, float fTime)
|
||||
void Dungeon::Update(olc::PixelGameEngine* engine, float fTime)
|
||||
{
|
||||
ActiveCamera->Update(fTime);
|
||||
|
||||
if (!HasBegun) return;
|
||||
|
||||
// spawn enemies
|
||||
if (Enemies.size() == 0)// rand() % 1000 < 1)
|
||||
{
|
||||
Enemy* enemy = new Enemy();
|
||||
enemy->Type = EEntity::Type::Enemy;
|
||||
enemy->Renderable = EnemyRenderable;
|
||||
enemy->Animator = EnemyAnimator;
|
||||
enemy->Coords = { Player->Coords.x + static_cast<float>((rand() % 100) - 50 ), Player->Coords.y + static_cast<float>((rand() % 100) - 50) };
|
||||
|
||||
enemy->HitBox = new Collider{ 0, 0, 28, 36 };
|
||||
|
||||
Enemies.push_back(enemy);
|
||||
}
|
||||
|
||||
olc::vf2d desiredLocation = Player->Coords;
|
||||
for (auto enemy : Enemies)
|
||||
{
|
||||
enemy->Velocity = static_cast<float>(TileSize) * (fTime * (Player->Speed / 3.0f) * olc::vf2d(desiredLocation - enemy->Coords).norm());
|
||||
|
||||
enemy->Coords += enemy->Velocity;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
olc::Pixel pixelMultiply(const int x, const int y, const olc::Pixel& pSource, const olc::Pixel& pDest)
|
||||
@@ -447,7 +520,7 @@ void Dungeon::Draw(olc::PixelGameEngine* engine, float fTime)
|
||||
// Entities are always (tilesize / 3) * 2
|
||||
|
||||
// Dungeon Layer
|
||||
engine->SetDrawTarget(3);
|
||||
engine->SetDrawTarget(4);
|
||||
engine->Clear({38, 36, 40});
|
||||
|
||||
engine->SetPixelMode(olc::Pixel::ALPHA);
|
||||
@@ -456,25 +529,67 @@ void Dungeon::Draw(olc::PixelGameEngine* engine, float fTime)
|
||||
engine->DrawPartialDecal({ static_cast<float>((tile.first.x * TileSize) - ActiveCamera->Coords.x), static_cast<float>((tile.first.y * TileSize) - ActiveCamera->Coords.y) },
|
||||
{ static_cast<float>(TileSize), static_cast<float>(TileSize) }, TileSet->Decal(), TileSetDictionary->Dictionary[tile.second->Type], { 16, 16 });
|
||||
|
||||
|
||||
// Entity Layer
|
||||
engine->SetDrawTarget(2);
|
||||
engine->SetDrawTarget(3);
|
||||
engine->Clear(olc::BLANK);
|
||||
|
||||
// Draw character
|
||||
Player->Animator->Draw(fTime, {Player->Coords.x - ActiveCamera->Coords.x, Player->Coords.y - ActiveCamera->Coords.y});
|
||||
|
||||
for (int i = 0; i < Enemies.size(); i++)
|
||||
{
|
||||
_Logger.Debug(i);
|
||||
Enemies[i]->Animator->SetState("idle");
|
||||
Enemies[i]->Animator->Draw(fTime, {Enemies[i]->Coords.x - ActiveCamera->Coords.x, Enemies[i]->Coords.y - ActiveCamera->Coords.y});
|
||||
}
|
||||
|
||||
// Lighting layers
|
||||
engine->SetDrawTarget(1);
|
||||
engine->SetDrawTarget(2);
|
||||
engine->Clear(olc::BLANK);
|
||||
|
||||
static bool WasFireLit = false;
|
||||
static bool HasFireLit = false;
|
||||
static float FireAccumilator = 0.0f;
|
||||
|
||||
if (engine->GetKey(olc::F).bPressed) IsFireLit = true;
|
||||
|
||||
if (!IsLightOn && !HasFireLit)
|
||||
{
|
||||
engine->FillRectDecal({0.0f, 0.0f}, {static_cast<float>(engine->ScreenWidth()), static_cast<float>(engine->ScreenHeight())}, olc::Pixel(0,0,0));
|
||||
}
|
||||
|
||||
if (!IsFireLit) return;
|
||||
|
||||
// Wait for fire to get going to render
|
||||
if (WasFireLit != IsFireLit)
|
||||
{
|
||||
SoundFireLighting.setPlayingOffset(sf::seconds(0.3f));
|
||||
SoundFireLighting.play();
|
||||
}
|
||||
WasFireLit = true;
|
||||
static bool LastPlayFire = false;
|
||||
static bool PlayFire = false;
|
||||
FireAccumilator += fTime;
|
||||
if (FireAccumilator > 1.4f)
|
||||
PlayFire = true;
|
||||
if (FireAccumilator < 1.4f)
|
||||
return;
|
||||
if (LastPlayFire != PlayFire)
|
||||
{
|
||||
SoundFire.play();
|
||||
LastPlayFire = true;
|
||||
HasFireLit = true;
|
||||
}
|
||||
|
||||
HasBegun = true;
|
||||
|
||||
static std::function<olc::Pixel(const int x, const int y, const olc::Pixel& pSource, const olc::Pixel& pDest)> fPixelMultiply = pixelMultiply;
|
||||
|
||||
// loads to make it more chaotic
|
||||
float lightScale = 1.4f + GetNextPerlin(); GetNextPerlin(); GetNextPerlin(); GetNextPerlin(); GetNextPerlin();
|
||||
float lightScale = 1.2f + GetNextPerlin(); GetNextPerlin(); GetNextPerlin(); GetNextPerlin(); GetNextPerlin();
|
||||
|
||||
float lightX = static_cast<float>(Player->Coords.x - ActiveCamera->Coords.x) - ((FireOverlay->Sprite()->width * lightScale) / 2.0f);
|
||||
float lightY = static_cast<float>(Player->Coords.y - ActiveCamera->Coords.y) - ((FireOverlay->Sprite()->height * lightScale) / 2.0f);
|
||||
float lightX = static_cast<float>(Player->Coords.x - ActiveCamera->Coords.x) - ((FireOverlay->Sprite()->width * lightScale) / 2.0f) + static_cast<float>(Player->HitBox->w) / 2.0f;
|
||||
float lightY = static_cast<float>(Player->Coords.y - ActiveCamera->Coords.y) - ((FireOverlay->Sprite()->height * lightScale) / 2.0f) + static_cast<float>(Player->HitBox->h) / 2.0f;
|
||||
|
||||
float lightLeft = lightX + 1.0f;
|
||||
float lightRight = lightX + FireOverlay->Sprite()->width * lightScale - 1.0f;
|
||||
@@ -511,10 +626,12 @@ Dungeon::~Dungeon()
|
||||
delete TileSet;
|
||||
for (std::pair<olc::vi2d, Tile*> tile : DungeonTiles)
|
||||
delete tile.second;
|
||||
for (std::pair<olc::vi2d, Entity*> entity : Entities)
|
||||
delete entity.second;
|
||||
for (std::pair<olc::vi2d, FixedItem*> entity : FixedItems)
|
||||
delete entity.second;
|
||||
|
||||
for (auto enemy : Enemies)
|
||||
{
|
||||
delete enemy->HitBox;
|
||||
delete enemy;
|
||||
}
|
||||
|
||||
free(perlinSeed);
|
||||
free(perlinOutput);
|
||||
|
||||
@@ -2,8 +2,11 @@
|
||||
#define GREATMACHINE_DUNGEON_H_
|
||||
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include <SFML/Audio.hpp>
|
||||
#include "olcPixelGameEngine.hpp"
|
||||
#include "olcPGEX_AnimatedSprite.hpp"
|
||||
|
||||
#include "Logger.hpp"
|
||||
|
||||
@@ -11,6 +14,7 @@ class Camera;
|
||||
|
||||
class Tile;
|
||||
class Entity;
|
||||
class Enemy;
|
||||
class Playable;
|
||||
class FixedItem;
|
||||
class TileDictionary;
|
||||
@@ -22,27 +26,42 @@ class Dungeon
|
||||
Dungeon();
|
||||
|
||||
void Generate();
|
||||
void SpawnEntity(Entity* entity);
|
||||
|
||||
void Input(olc::PixelGameEngine* engine, float fTime);
|
||||
void Update(olc::PixelGameEngine* engine, float fTime);
|
||||
void Draw(olc::PixelGameEngine* engine, float fTime);
|
||||
|
||||
bool HasBegun = false;
|
||||
|
||||
Playable* Player;
|
||||
Camera* ActiveCamera;
|
||||
|
||||
olc::Renderable* EnemyRenderable;
|
||||
olc::AnimatedSprite* EnemyAnimator;
|
||||
std::vector<Enemy*> Enemies;
|
||||
|
||||
int TileSize = 64;
|
||||
|
||||
int DungeonWidth;
|
||||
int DungeonHeight;
|
||||
std::unordered_map<olc::vi2d, Tile*> DungeonTiles;
|
||||
std::unordered_map<olc::vf2d, Entity*> Entities;
|
||||
std::unordered_map<olc::vf2d, FixedItem*> FixedItems;
|
||||
|
||||
TileDictionary* TileSetDictionary;
|
||||
olc::Renderable* TileSet;
|
||||
olc::Renderable* FireOverlay;
|
||||
|
||||
bool IsFireLit = false;
|
||||
bool IsLightOn = true;
|
||||
sf::SoundBuffer SoundBufferFireLighting;
|
||||
sf::Sound SoundFireLighting;
|
||||
sf::SoundBuffer SoundBufferFire;
|
||||
sf::Sound SoundFire;
|
||||
|
||||
sf::SoundBuffer SoundBufferAmbient;
|
||||
sf::Sound SoundAmbient;
|
||||
sf::SoundBuffer SoundBufferFootsteps;
|
||||
sf::Sound SoundFootsteps;
|
||||
|
||||
~Dungeon();
|
||||
|
||||
private:
|
||||
|
||||
@@ -257,6 +257,7 @@ class Logger
|
||||
public:
|
||||
|
||||
std::atomic<bool> _IsRunning = false;
|
||||
std::atomic<bool> _Terminate = false;
|
||||
|
||||
std::condition_variable _TaskEnqueued;
|
||||
std::queue<LogEntity*> _LogQueue;
|
||||
|
||||
@@ -81,6 +81,7 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<LibraryPath>$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
@@ -116,11 +117,14 @@
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<AdditionalIncludeDirectories>;C:\dev\SFML\include</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>C:\dev\SFML\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>sfml-main.lib;sfml-audio.lib;sfml-system.lib</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@@ -132,12 +136,15 @@
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<AdditionalIncludeDirectories>C:\dev\SFML\include;%(AdditionalIncludeDirectories);C:\dev\SFML\include</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>sfml-main.lib;sfml-audio.lib;sfml-system.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>C:\dev\SFML\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LocalDebuggerWorkingDirectory>$(ProjectDir)/../</LocalDebuggerWorkingDirectory>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LocalDebuggerWorkingDirectory>$(ProjectDir)/../</LocalDebuggerWorkingDirectory>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -129,6 +129,12 @@ class Playable : public Entity
|
||||
std::array<Item*, 6> Inventory;
|
||||
};
|
||||
|
||||
class Enemy : public Entity
|
||||
{
|
||||
public:
|
||||
olc::vf2d Velocity = { 0.0f, 0.0f };
|
||||
};
|
||||
|
||||
|
||||
class TileDictionary
|
||||
{
|
||||
|
||||
@@ -29,34 +29,82 @@ class Game : public olc::PixelGameEngine
|
||||
for (int i = 0; i < 5; i++)
|
||||
CreateLayer();
|
||||
|
||||
SetDrawTarget(uint8_t(0));
|
||||
Clear(olc::BLANK);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DisplayTitle(float fTime)
|
||||
{
|
||||
if (m_TimeAccumilator > 2.0f)
|
||||
{
|
||||
m_DeltaFade -= fTime * 200.0f;
|
||||
if (m_DeltaFade < 0.1f) m_DeltaFade = 0.0f;
|
||||
}
|
||||
DrawString((ScreenWidth() / 2) - (7 * 7) * (std::string("The Great Machine").length() / 2), ScreenHeight() / 2, "The Great Machine", olc::Pixel(255, 255, 255, static_cast<int>(m_DeltaFade)), 6);
|
||||
DrawString(5, ScreenHeight() - 15, "Powered by the OLC Pixel Game Engine", olc::Pixel(255, 255, 255, static_cast<int>(m_DeltaFade)));
|
||||
DrawString(ScreenWidth() - (8 * (std::string("Copyright Benjamin Kyd 2020").length())) - 5, ScreenHeight() - 15, "Copyright Benjamin Kyd 2020", olc::Pixel(255, 255, 255, static_cast<int>(m_DeltaFade)));
|
||||
DrawString((ScreenWidth() / 2) - (7 * 7) * (std::string("The Great Machine").length() / 2), ScreenHeight() / 2, "The Great Machine", olc::Pixel(255, 255, 255, static_cast<int>(_DeltaFade)), 6);
|
||||
DrawString(5, ScreenHeight() - 15, "Powered by the OLC Pixel Game Engine", olc::Pixel(255, 255, 255, static_cast<int>(_DeltaFade)));
|
||||
DrawString(ScreenWidth() - (8 * (std::string("Copyright Benjamin Kyd 2020").length())) - 5, ScreenHeight() - 15, "Copyright Benjamin Kyd 2020", olc::Pixel(255, 255, 255, static_cast<int>(_DeltaFade)));
|
||||
}
|
||||
|
||||
bool OnUserUpdate(float fTime) override
|
||||
{
|
||||
m_TimeAccumilator += fTime;
|
||||
_TimeAccumilator += fTime;
|
||||
|
||||
Clear({38, 36, 40});
|
||||
|
||||
// _Logger.Debug(m_TimeAccumilator);
|
||||
|
||||
//if (m_TimeAccumilator < 4.0f)
|
||||
//{
|
||||
//DisplayTitle(fTime);
|
||||
//return true;
|
||||
//}
|
||||
SetDrawTarget(uint8_t(0));
|
||||
Clear(olc::BLANK);
|
||||
goto bruh;
|
||||
|
||||
if (_TimeAccumilator < 6.0f)
|
||||
{
|
||||
Clear({38, 36, 40});
|
||||
if (_TimeAccumilator > 4.0f)
|
||||
{
|
||||
_DeltaFade -= fTime * 200.0f;
|
||||
if (_DeltaFade < 0.1f) _DeltaFade = 0.0f;
|
||||
}
|
||||
DisplayTitle(fTime);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static bool IsFlicker = false;
|
||||
if (_TimeAccumilator > 10.0f && _TimeAccumilator < 27.0f)
|
||||
{
|
||||
if (rand() % 60 < 1)
|
||||
IsFlicker = true;
|
||||
if (rand() % 20 < 1)
|
||||
IsFlicker = false;
|
||||
|
||||
if (IsFlicker)
|
||||
_Dungeon->IsLightOn = true;
|
||||
else
|
||||
_Dungeon->IsLightOn = false;
|
||||
|
||||
if (_TimeAccumilator > 13.0f)
|
||||
{
|
||||
_Dungeon->IsLightOn = false;
|
||||
|
||||
if (_TimeAccumilator > 26.0f)
|
||||
{
|
||||
_DeltaFade1 -= fTime * 200.0f;
|
||||
if (_DeltaFade1 < 0.1f) _DeltaFade1 = 0.0f;
|
||||
}
|
||||
|
||||
SetPixelMode(olc::Pixel::ALPHA);
|
||||
if (_TimeAccumilator > 16.0f)
|
||||
DrawString((ScreenWidth() / 2) - (7 * 3) * (std::string("the machine has done nothing for me").length() / 2), 40, "the machine has done nothing for me", olc::Pixel(255, 255, 255, static_cast<int>(_DeltaFade1)), 3);
|
||||
if (_TimeAccumilator > 20.0f)
|
||||
DrawString((ScreenWidth() / 2) - (7 * 3) * (std::string("the machine has left me with nothing").length() / 2), 120, "the machine has left me with nothing", olc::Pixel(255, 255, 255, static_cast<int>(_DeltaFade1)), 3);
|
||||
if (_TimeAccumilator > 23.0f)
|
||||
DrawString((ScreenWidth() / 2) - (7 * 5) * (std::string("i am nothing").length() / 2), 300, "i am nothing", olc::Pixel(255, 255, 255, static_cast<int>(_DeltaFade1)), 5);
|
||||
}
|
||||
}
|
||||
|
||||
if (_TimeAccumilator > 26.0f)
|
||||
{
|
||||
_Dungeon->IsFireLit = true;
|
||||
}
|
||||
|
||||
bruh:
|
||||
|
||||
_Dungeon->Input(this, fTime);
|
||||
|
||||
@@ -70,19 +118,27 @@ class Game : public olc::PixelGameEngine
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OnUserDestroy() override
|
||||
{
|
||||
delete _Dungeon;
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
long float m_TimeAccumilator = 0;
|
||||
|
||||
float m_DeltaFade = 255.0f;
|
||||
long float _TimeAccumilator = 0.0f;
|
||||
|
||||
float _DeltaFade = 255.0f;
|
||||
float _DeltaFade1 = 255.0f;
|
||||
};
|
||||
|
||||
#include <SFML/Audio.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
Logger& _Logger = Logger::getInstance();
|
||||
_Logger.InitializeFileLogging("./logs.log");
|
||||
_Logger.InitializeLoggingThread();
|
||||
_Logger.Debug("Initializing");
|
||||
|
||||
Game _Game;
|
||||
_Game.Construct(1280, 720, 1, 1, false, false);
|
||||
@@ -92,4 +148,6 @@ int main()
|
||||
{
|
||||
_Logger.Panic("PGE Cannot start");
|
||||
}
|
||||
|
||||
_Logger.~Logger();
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 63 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 17 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 36 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 79 KiB |
BIN
res/ambient.ogg
Normal file
BIN
res/ambient.ogg
Normal file
Binary file not shown.
BIN
res/fire.wav
Normal file
BIN
res/fire.wav
Normal file
Binary file not shown.
BIN
res/fire_start.wav
Normal file
BIN
res/fire_start.wav
Normal file
Binary file not shown.
BIN
res/run.ogg
Normal file
BIN
res/run.ogg
Normal file
Binary file not shown.
BIN
sfml-audio-2.dll
Normal file
BIN
sfml-audio-2.dll
Normal file
Binary file not shown.
BIN
sfml-system-2.dll
Normal file
BIN
sfml-system-2.dll
Normal file
Binary file not shown.
Reference in New Issue
Block a user