generated from sigonasr2/CPlusPlusProjectTemplate
Particle system started
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
ca4134fbb9
commit
d457d88258
Binary file not shown.
10
defines.h
Normal file
10
defines.h
Normal file
@ -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
|
28
main.cpp
28
main.cpp
@ -3,6 +3,7 @@
|
|||||||
#define OLC_PGEX_SPLASHSCREEN
|
#define OLC_PGEX_SPLASHSCREEN
|
||||||
#include "splash.h"
|
#include "splash.h"
|
||||||
#define OLC_SOUNDWAVE
|
#define OLC_SOUNDWAVE
|
||||||
|
#include "defines.h"
|
||||||
#include "soundwaveEngine.h"
|
#include "soundwaveEngine.h"
|
||||||
#include "tiles.h"
|
#include "tiles.h"
|
||||||
#include "references.h"
|
#include "references.h"
|
||||||
@ -11,16 +12,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "cutscene.h"
|
#include "cutscene.h"
|
||||||
#include "encounters.h"
|
#include "encounters.h"
|
||||||
|
#include "particle.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
|
|
||||||
|
|
||||||
#define ㅎ
|
#define ㅎ
|
||||||
#define ㅍ
|
#define ㅍ
|
||||||
@ -540,6 +532,8 @@ public:
|
|||||||
std::map<std::string,Animation*> ANIMATIONS;
|
std::map<std::string,Animation*> ANIMATIONS;
|
||||||
std::map<int,Object*> OBJ_INFO;
|
std::map<int,Object*> OBJ_INFO;
|
||||||
|
|
||||||
|
std::vector<Particle*> PARTICLES;
|
||||||
|
|
||||||
bool OnUserCreate() override
|
bool OnUserCreate() override
|
||||||
{
|
{
|
||||||
srand(time(NULL));
|
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!
|
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;
|
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;i<PARTICLES.size();i++) {
|
||||||
|
PARTICLES[i]->update();
|
||||||
|
PARTICLES[i]->particleUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
if (GetCurrentCutsceneAction()!=ActionType::NONE) {
|
if (GetCurrentCutsceneAction()!=ActionType::NONE) {
|
||||||
CurrentAction=GetCurrentCutsceneAction();
|
CurrentAction=GetCurrentCutsceneAction();
|
||||||
CurrentCutscene->LockAction();
|
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);
|
DrawStringPropDecal({6,6},messageBoxText);
|
||||||
}
|
}
|
||||||
SetDrawTarget(layer::INTERFACE);
|
SetDrawTarget(layer::INTERFACE);
|
||||||
|
for (int i=0;i<PARTICLES.size();i++) {
|
||||||
|
PARTICLES[i]->render(this);
|
||||||
|
}
|
||||||
FillRectDecal({0,0},{WIDTH,HEIGHT},Pixel(0,0,0,(int)CUTSCENE_FADE_VALUE));
|
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;
|
pixelOffsetY=0;
|
||||||
}
|
}
|
||||||
SetDrawTarget(layer::DYNAMIC);
|
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 {
|
} else {
|
||||||
SetDrawTarget(layer::DYNAMIC);
|
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);
|
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);
|
||||||
|
53
particle.h
Normal file
53
particle.h
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user