diff --git a/C++ProjectTemplate b/C++ProjectTemplate index d77a206..e79c68e 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/defines.h b/defines.h new file mode 100644 index 0000000..ddcff4f --- /dev/null +++ b/defines.h @@ -0,0 +1,10 @@ + +#define WIDTH 256 +#define HEIGHT 224 +#define TILEMAP_SIZE_X 512 +#define TILEMAP_SIZE_Y 512 +#define TILEMAP_EDITOR_DRAW_MULT 0.4375 +#define TILEMAP_EDITOR_TILESIZE (32*TILEMAP_EDITOR_DRAW_MULT) +#define PARTY_TRAIL_LENGTH 48 +#define CAMERA_WAIT_TIME 60 +#define HEALTH_ROLLING_SPEED 2 \ No newline at end of file diff --git a/main.cpp b/main.cpp index 023a81d..8f92505 100644 --- a/main.cpp +++ b/main.cpp @@ -3,6 +3,7 @@ #define OLC_PGEX_SPLASHSCREEN #include "splash.h" #define OLC_SOUNDWAVE +#include "defines.h" #include "soundwaveEngine.h" #include "tiles.h" #include "references.h" @@ -11,16 +12,7 @@ #include #include "cutscene.h" #include "encounters.h" - -#define WIDTH 256 -#define HEIGHT 224 -#define TILEMAP_SIZE_X 512 -#define TILEMAP_SIZE_Y 512 -#define TILEMAP_EDITOR_DRAW_MULT 0.4375 -#define TILEMAP_EDITOR_TILESIZE (32*TILEMAP_EDITOR_DRAW_MULT) -#define PARTY_TRAIL_LENGTH 48 -#define CAMERA_WAIT_TIME 60 -#define HEALTH_ROLLING_SPEED 2 +#include "particle.h" #define ㅎ #define ㅍ @@ -540,6 +532,8 @@ public: std::map ANIMATIONS; std::map OBJ_INFO; + std::vector PARTICLES; + bool OnUserCreate() override { srand(time(NULL)); @@ -602,6 +596,10 @@ in some form or capacity or another. Even though it goes on a very long time, I hope you can understand this is only for testing purposes! )");*/ + for (int i=0;i<1000;i++) { + PARTICLES.push_back(new LineParticle({rand()%WIDTH,rand()%HEIGHT},{rand()%10-5,rand()%10-5},{0,0},rand()%1000,Pixel(rand()%255,rand()%255,rand()%255),true)); + } + return true; } @@ -668,6 +666,11 @@ goes on a very long time, I hope you can understand this is only for testing pur } } + for (int i=0;iupdate(); + PARTICLES[i]->particleUpdate(); + } + if (GetCurrentCutsceneAction()!=ActionType::NONE) { CurrentAction=GetCurrentCutsceneAction(); CurrentCutscene->LockAction(); @@ -1572,6 +1575,9 @@ goes on a very long time, I hope you can understand this is only for testing pur DrawStringPropDecal({6,6},messageBoxText); } SetDrawTarget(layer::INTERFACE); + for (int i=0;irender(this); + } FillRectDecal({0,0},{WIDTH,HEIGHT},Pixel(0,0,0,(int)CUTSCENE_FADE_VALUE)); }; @@ -1614,7 +1620,7 @@ goes on a very long time, I hope you can understand this is only for testing pur pixelOffsetY=0; } SetDrawTarget(layer::DYNAMIC); - DrawPartialDecal(obj->GetPos()-cameraPos,obj->spr->spr,{(float)((obj->frameIndex%obj->spr->frames)*obj->spr->width),0},{(float)obj->spr->width,(float)obj->spr->spr->sprite->height},obj->GetScale(),Pixel(obj->color.r,obj->color.g,obj->color.b,abs(sin(M_PI/60*frameCount)*210))); + DrawPartialDecal(obj->GetPos()-cameraPos,obj->spr->spr,{(float)((obj->frameIndex%obj->spr->frames)*obj->spr->width),0},{(float)obj->spr->width,(float)obj->spr->spr->sprite->height},obj->GetScale(),obj->color); } else { SetDrawTarget(layer::DYNAMIC); DrawPartialDecal(obj->GetPos()-cameraPos,obj->spr->spr,{(float)((obj->frameIndex%obj->spr->frames)*obj->spr->width),0},{(float)obj->spr->width,(float)obj->spr->spr->sprite->height},obj->GetScale(),obj->color); diff --git a/particle.h b/particle.h new file mode 100644 index 0000000..1a010f4 --- /dev/null +++ b/particle.h @@ -0,0 +1,53 @@ +class Particle{ + public: + vd2d pos; + vd2d spd; + vd2d acc; + int lifetime; //In frames. + bool wrap; + Particle(vd2d pos,vd2d spd,vd2d acc,int lifetime,bool wrap=false) + :pos(pos),spd(spd),acc(acc),lifetime(lifetime){}; + virtual void render(PixelGameEngine*game)=0; + virtual void particleUpdate()=0; + void update() { + spd+=acc; + pos+=spd; + if (wrap) { + if (pos.x<0) { + pos.x+=WIDTH; + } else + if (pos.y<0) { + pos.y+=HEIGHT; + } + if (pos.x>WIDTH) { + pos.x-=WIDTH; + } else + if (pos.y>HEIGHT) { + pos.y-=HEIGHT; + } + } + } + vd2d GetPos() { + return pos; + } + vd2d GetSpd() { + return spd; + } + vd2d GetAcc() { + return acc; + } + void SetPos(vd2d pos) { + this->pos=pos; + } +}; + +class LineParticle:public Particle{ + public: + Pixel col; + LineParticle(vd2d pos,vd2d spd,vd2d acc,int lifetime,Pixel col=WHITE,bool wrap=false) + :col(col),Particle(pos,spd,acc,lifetime,wrap){} + void particleUpdate()override{} + void render(PixelGameEngine*game)override{ + game->DrawLineDecal(pos,pos+spd,col); + } +}; \ No newline at end of file