The open source repository for the action RPG game in development by Sig Productions titled 'Adventures in Lestoria'! https://forums.lestoria.net
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.
AdventuresInLestoria/Crawler/Crawler.h

79 lines
2.3 KiB

#pragma once
#include "olcPixelGameEngine.h"
#include "Animation.h"
#include "olcUTIL_Animate2D.h"
#include "Monster.h"
#include "olcPGEX_TransformedView.h"
#include "Player.h"
#include "olcUTIL_Camera2D.h"
#include "Effect.h"
#include "Map.h"
#include "TMXParser.h"
struct TilesheetData{
TilesetData&tileset;
int firstgid;
};
class Crawler : public olc::PixelGameEngine
{
Camera2D camera;
Player player;
Renderable GFX_Warrior_Sheet,GFX_Slime_Sheet,GFX_Circle,
GFX_Effect_GroundSlam_Back,GFX_Effect_GroundSlam_Front,
GFX_Heart,GFX_BLOCK_BUBBLE,GFX_Ranger_Sheet,GFX_Wizard_Sheet,
GFX_Battlecry_Effect,GFX_Mana,GFX_SonicSlash;
public:
Renderable GFX_BulletCircle,GFX_BulletCircleOutline;
private:
std::vector<Effect>foregroundEffects,backgroundEffects;
std::map<MapName,Map>MAP_DATA;
std::map<std::string,TilesetData>MAP_TILESETS;
vf2d worldShake={};
float worldShakeTime=0;
float lastWorldShakeAdjust=0;
vf2d worldShakeVel={};
const float WORLD_SHAKE_ADJUST_MAX_TIME=0.4;
MapName currentLevel=MapName::CAMPAIGN_1_1;
std::vector<TileGroup>foregroundTileGroups;
public:
Crawler();
public:
vi2d WORLD_SIZE={120,8};
TileTransformedView view;
bool OnUserCreate() override;
bool OnUserUpdate(float fElapsedTime) override;
void InitializeAnimations();
void InitializeLevel(std::string mapFile,MapName map);
void LoadLevel(MapName map);
void HandleUserInput(float fElapsedTime);
void UpdateCamera(float fElapsedTime);
void UpdateEffects(float fElapsedTime);
void UpdateBullets(float fElapsedTime);
void RenderWorld(float fElapsedTime);
void RenderHud();
void AddEffect(Effect foreground,Effect background);
//If back is true, places the effect in the background
void AddEffect(Effect foreground,bool back=false);
void HurtEnemies(vf2d pos,float radius,int damage);
vf2d GetWorldMousePos();
bool LeftHeld();
bool RightHeld();
bool UpHeld();
bool DownHeld();
bool LeftReleased();
bool RightReleased();
bool UpReleased();
bool DownReleased();
Player&GetPlayer();
void SetupWorldShake(float duration);
vi2d GetWorldSize();
//tileID is the tile number from the tilesets.
bool IsForegroundTile(TilesheetData sheet,int tileID);
//tileID is the tile number from the tilesets.
TilesheetData GetTileSheet(MapName map,int tileID);
geom2d::rect<int>GetTileCollision(MapName map,vf2d pos);
MapName GetCurrentLevel();
};