You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
1.9 KiB
72 lines
1.9 KiB
#include "olcPixelGameEngine.h"
|
|
#include "olcSoundWaveEngine.h"
|
|
#include "olcPGEX_TransformedView.h"
|
|
#include "Unit.h"
|
|
#include "Constant.h"
|
|
#include "Image.h"
|
|
#include "DeathAnimation.h"
|
|
#include "olcPGEX_AudioListener.h"
|
|
#include "olcPGEX_AudioSource.h"
|
|
#include "Sound.h"
|
|
|
|
struct Letter{
|
|
vf2d pos;
|
|
float spd;
|
|
char c;
|
|
};
|
|
|
|
class VirusAttack : public olc::PixelGameEngine
|
|
{
|
|
class CollectionPoint{
|
|
public:
|
|
vf2d pos;
|
|
Renderable img;
|
|
Sprite*originalCollectionPointImg;
|
|
MemoryType type;
|
|
vf2d randomOffset;
|
|
float rot;
|
|
CollectionPoint(PixelGameEngine*pge,vf2d pos,float rot,Renderable&collectionPointImg,MemoryType type);
|
|
void Update(PixelGameEngine*pge,Renderable&matrixImg);
|
|
};
|
|
private:
|
|
std::vector<std::shared_ptr<Unit>>units;
|
|
std::vector<std::unique_ptr<CollectionPoint>>collectionPoints;
|
|
std::vector<std::unique_ptr<DeathAnimation>>deathAnimations;
|
|
|
|
std::map<Image,std::unique_ptr<Renderable>>IMAGES;
|
|
std::map<Sound,std::unique_ptr<Audio>>SOUNDS;
|
|
|
|
olcPGEX_AudioListener AL;
|
|
Audio*bgm;
|
|
|
|
TileTransformedView game;
|
|
|
|
float matrixTimer=0;
|
|
float updatePixelsTimer=0;
|
|
const std::array<char,16>matrixLetters={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F',};
|
|
std::vector<Letter>activeLetters;
|
|
|
|
vf2d startingDragPos=CONSTANT::UNSELECTED;
|
|
void HandleDraggingSelection();
|
|
void DrawSelectionRectangle();
|
|
void HandleRightClickMove();
|
|
void CollisionChecking(std::shared_ptr<Unit>u,std::shared_ptr<Unit>u2);
|
|
void IdentifyClosestTarget(std::weak_ptr<Unit>&closestUnit,float&closestDist,std::shared_ptr<Unit>u,std::shared_ptr<Unit>u2);
|
|
vf2d GetWorldMousePos();
|
|
void HandlePanAndZoom(float fElapsedTime);
|
|
void DrawMinimap();
|
|
void HandleMinimapClick();
|
|
void InitializeImages();
|
|
void UpdateMatrixTexture(float fElapsedTime);
|
|
void RenderCollectionPoints(CollectionPoint*cp);
|
|
void RenderFogOfWar();
|
|
void InitializeSounds();
|
|
|
|
public:
|
|
VirusAttack();
|
|
|
|
public:
|
|
bool OnUserCreate() override;
|
|
|
|
bool OnUserUpdate(float fElapsedTime) override;
|
|
}; |