2023-06-11 22:57:43 -05:00
|
|
|
#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"
|
2023-06-15 00:11:39 -05:00
|
|
|
#include "Effect.h"
|
2023-06-21 14:30:14 -07:00
|
|
|
#include "Map.h"
|
|
|
|
#include "TMXParser.h"
|
|
|
|
|
2023-06-22 04:34:23 -07:00
|
|
|
struct TilesheetData{
|
2023-06-22 22:09:11 -07:00
|
|
|
TilesetData&tileset;
|
2023-06-22 04:34:23 -07:00
|
|
|
int firstgid;
|
|
|
|
};
|
2023-06-11 22:57:43 -05:00
|
|
|
|
|
|
|
class Crawler : public olc::PixelGameEngine
|
|
|
|
{
|
|
|
|
Camera2D camera;
|
|
|
|
Player player;
|
2023-06-17 23:07:26 -05:00
|
|
|
Renderable GFX_Warrior_Sheet,GFX_Slime_Sheet,GFX_Circle,
|
2023-06-16 01:59:46 -05:00
|
|
|
GFX_Effect_GroundSlam_Back,GFX_Effect_GroundSlam_Front,
|
2023-06-19 03:25:01 -05:00
|
|
|
GFX_Heart,GFX_BLOCK_BUBBLE,GFX_Ranger_Sheet,GFX_Wizard_Sheet,
|
2023-07-05 05:34:21 -05:00
|
|
|
GFX_Battlecry_Effect,GFX_Mana,GFX_SonicSlash,GFX_EnergyParticle,
|
|
|
|
GFX_Splash_Effect;
|
2023-06-24 01:18:21 -07:00
|
|
|
public:
|
2023-06-24 02:14:11 -07:00
|
|
|
Renderable GFX_BulletCircle,GFX_BulletCircleOutline,GFX_EnergyBolt;
|
2023-06-24 01:18:21 -07:00
|
|
|
private:
|
2023-06-15 00:11:39 -05:00
|
|
|
std::vector<Effect>foregroundEffects,backgroundEffects;
|
2023-06-21 14:30:14 -07:00
|
|
|
std::map<MapName,Map>MAP_DATA;
|
2023-06-22 22:09:11 -07:00
|
|
|
std::map<std::string,TilesetData>MAP_TILESETS;
|
2023-06-20 19:13:45 -07:00
|
|
|
vf2d worldShake={};
|
|
|
|
float worldShakeTime=0;
|
|
|
|
float lastWorldShakeAdjust=0;
|
|
|
|
vf2d worldShakeVel={};
|
|
|
|
const float WORLD_SHAKE_ADJUST_MAX_TIME=0.4;
|
2023-06-22 02:46:38 -07:00
|
|
|
MapName currentLevel=MapName::CAMPAIGN_1_1;
|
2023-06-22 23:28:16 -07:00
|
|
|
std::vector<TileGroup>foregroundTileGroups;
|
2023-06-11 22:57:43 -05:00
|
|
|
|
|
|
|
public:
|
|
|
|
Crawler();
|
|
|
|
|
|
|
|
public:
|
2023-07-05 18:29:04 +00:00
|
|
|
geom2d::rect<int>NO_COLLISION={};
|
2023-06-23 20:42:55 -07:00
|
|
|
vi2d WORLD_SIZE={120,8};
|
2023-06-15 00:11:39 -05:00
|
|
|
TileTransformedView view;
|
2023-06-11 22:57:43 -05:00
|
|
|
bool OnUserCreate() override;
|
|
|
|
bool OnUserUpdate(float fElapsedTime) override;
|
|
|
|
void InitializeAnimations();
|
2023-06-21 22:59:06 -07:00
|
|
|
void InitializeLevel(std::string mapFile,MapName map);
|
2023-06-22 02:46:38 -07:00
|
|
|
void LoadLevel(MapName map);
|
2023-06-11 22:57:43 -05:00
|
|
|
void HandleUserInput(float fElapsedTime);
|
|
|
|
void UpdateCamera(float fElapsedTime);
|
2023-06-15 00:11:39 -05:00
|
|
|
void UpdateEffects(float fElapsedTime);
|
2023-06-16 01:41:38 -05:00
|
|
|
void UpdateBullets(float fElapsedTime);
|
2023-06-12 00:37:55 -05:00
|
|
|
void RenderWorld(float fElapsedTime);
|
2023-06-15 00:47:11 -05:00
|
|
|
void RenderHud();
|
2023-06-15 00:11:39 -05:00
|
|
|
void AddEffect(Effect foreground,Effect background);
|
2023-06-19 03:25:01 -05:00
|
|
|
//If back is true, places the effect in the background
|
|
|
|
void AddEffect(Effect foreground,bool back=false);
|
2023-06-15 00:47:11 -05:00
|
|
|
void HurtEnemies(vf2d pos,float radius,int damage);
|
2023-06-15 04:53:57 -05:00
|
|
|
vf2d GetWorldMousePos();
|
2023-06-15 05:06:50 -05:00
|
|
|
bool LeftHeld();
|
|
|
|
bool RightHeld();
|
|
|
|
bool UpHeld();
|
|
|
|
bool DownHeld();
|
|
|
|
bool LeftReleased();
|
|
|
|
bool RightReleased();
|
|
|
|
bool UpReleased();
|
|
|
|
bool DownReleased();
|
2023-06-15 23:44:34 -05:00
|
|
|
Player&GetPlayer();
|
2023-06-20 19:13:45 -07:00
|
|
|
void SetupWorldShake(float duration);
|
2023-06-22 02:46:38 -07:00
|
|
|
vi2d GetWorldSize();
|
2023-06-22 04:34:23 -07:00
|
|
|
//tileID is the tile number from the tilesets.
|
2023-06-22 22:09:11 -07:00
|
|
|
bool IsForegroundTile(TilesheetData sheet,int tileID);
|
|
|
|
//tileID is the tile number from the tilesets.
|
2023-06-22 04:34:23 -07:00
|
|
|
TilesheetData GetTileSheet(MapName map,int tileID);
|
2023-07-05 18:29:04 +00:00
|
|
|
//Gets the rectangle of the tile collision at this tile.
|
2023-06-24 00:00:14 -07:00
|
|
|
geom2d::rect<int>GetTileCollision(MapName map,vf2d pos);
|
2023-07-05 18:29:04 +00:00
|
|
|
//Checks if the point resides inside of a collision tile.
|
2023-07-05 04:31:31 -05:00
|
|
|
bool HasTileCollision(MapName map,vf2d pos);
|
2023-06-24 00:00:14 -07:00
|
|
|
MapName GetCurrentLevel();
|
2023-06-11 22:57:43 -05:00
|
|
|
};
|