"smacks head with hand" oh yeah! forgot about the source...
here it is:
#include "DarkGDK.h"
const int PMAX=1000;
const int EXMAX=50;
const float g=1;
class pBase
{
public:
float x, y, xvel, yvel, life;
int Color, BGcolor;
pBase()
{
x=0;
y=0;
xvel=0;
yvel=0;
life=0;
}
void create()
{
x=0;
y=0;
xvel=0;
yvel=0;
life=0;
}
virtual void move()
{}
pBase(float cX, float cY, float cXvel, float cYvel, float cLife, int color, int bgcolor)
{
x=cX;
y=cY;
xvel=cXvel;
yvel=cYvel;
life=cLife;
Color=color;
BGcolor=bgcolor;
}
float getLife()
{
return life;
}
virtual void draw()
{}
};
class Volcanoe: public pBase
{
public:
Volcanoe()
{
x=0;
y=0;
xvel=0;
yvel=0;
life=0;
Color=0;
BGcolor=0;
}
Volcanoe (float cX, float cY, float cXvel, float cYvel, float cLife)
{
x=cX;
y=cY;
xvel=cXvel;
yvel=cYvel;
life=cLife;
Color=dbRGB(200, 0, 0);
BGcolor=dbRGB(50, 50, 200);
}
void create(float cX, float cY, float cXvel, float cYvel, float cLife)
{
x=cX;
y=cY;
xvel=cXvel;
yvel=cYvel;
life=cLife;
Color=dbRGB(200, 0, 0);
BGcolor=dbRGB(50, 50, 200);
}
void move()
{
x+=xvel;
y-=yvel;
yvel-=g;
life--;
}
void draw()
{
dbInk(Color, BGcolor);
dbCircle(x, y, 2);
dbCircle(x, y, 3);
dbCircle(x, y, 4);
}
};
class Swarm: public pBase
{
private:
float cpos;
bool dir;
public:
Swarm()
{
x=0;
y=0;
xvel=0;
yvel=0;
life=0;
Color=0;
BGcolor=0;
cpos=0;
dir=0;
}
Swarm(float cX, float cY, float Vel, float cLife)
{
x=cX;
y=cY;
xvel=Vel;
yvel=0;
life=cLife;
Color=dbRGB(0, 50, 0);
BGcolor=dbRGB(50, 50, 200);
cpos=0;
dir=dbRND(1);
}
void create(float cX, float cY, float Vel, float cLife)
{
x=cX;
y=cY;
xvel=Vel;
yvel=0;
life=cLife;
Color=dbRGB(0, 50, 0);
BGcolor=dbRGB(50, 50, 200);
cpos=0;
dir=dbRND(1);
}
void move()
{
if (dir==true)
cpos+=xvel;
else
cpos-=xvel;
x+=(dbSin(cpos)*2);
y+=(dbCos(cpos)*2);
life--;
}
void draw()
{
dbInk(Color, BGcolor);
dbCircle(x-6, y-8, 1);
dbCircle(x+6, y-8, 1);
dbCircle(x-5, y-6, 2);
dbCircle(x+5, y-6, 2);
dbCircle(x-3, y-3, 3);
dbCircle(x+3, y-3, 3);
dbCircle(x, y, 4);
}
};
class Fire: public pBase
{
private:
float wpos;
bool wdir;
public:
Fire()
{
x=0;
y=0;
xvel=0;
yvel=0;
life=0;
Color=0;
BGcolor=0;
wpos=0;
wdir=false;
}
Fire(float cX, float cY, float cYvel, float cLife)
{
x=cX;
y=cY;
xvel=0;
yvel=cYvel;
life=cLife;
Color=dbRGB(200, dbRND(200), 0);
BGcolor=dbRGB(50, 50, 200);
wpos=-3;
wdir=true;
}
void create(float cX, float cY, float cYvel, float cLife)
{
x=cX;
y=cY;
xvel=0;
yvel=cYvel;
life=cLife;
Color=dbRGB(200, dbRND(200), 0);
BGcolor=dbRGB(50, 50, 200);
wpos=-3;
wdir=true;
}
void move()
{
y-=yvel;
if (wdir==true)
{
wpos++;
if (wpos>2)
wdir=false;
}
else if (wdir==false)
{
wpos--;
if (wpos<-2)
wdir=true;
}
x+=wpos;
life--;
}
void draw()
{
dbInk(Color, BGcolor);
dbCircle(x+1, y-11, 1);
dbCircle(x, y-9, 2);
dbCircle(x-1, y-5, 3);
dbCircle(x, y, 4);
}
};
class Explode: public pBase
{
public:
Explode()
{
x=0;
y=0;
xvel=0;
yvel=0;
life=0;
Color=0;
BGcolor=0;
}
Explode (float cX, float cY, float Vel, float Dir, float cLife)
{
int temp=dbRND(200)+55;
x=cX;
y=cY;
xvel=Vel;
yvel=Dir;
life=cLife;
Color=dbRGB(temp, temp, temp);
BGcolor=dbRGB(50, 50, 200);
}
void create(float cX, float cY, float Vel, float Dir, float cLife)
{
int temp=dbRND(200)+55;
x=cX;
y=cY;
xvel=Vel;
yvel=Dir;
life=cLife;
Color=dbRGB(temp, temp, temp);
BGcolor=dbRGB(50, 50, 200);
}
void move()
{
x+=xvel*(dbSin(yvel));
y+=xvel*(dbCos(yvel));
life--;
}
void draw()
{
dbInk(Color, BGcolor);
dbCircle(x-4, y, 2);
dbCircle(x+4, y, 2);
dbCircle(x, y-4, 2);
dbCircle(x, y+4, 2);
dbCircle(x, y, 4);
}
};
class Bubbles: public pBase
{
private:
bool Dir;
int yAdd;
public:
Bubbles()
{
x=0;
y=0;
xvel=0;
yvel=0;
life=0;
Color=0;
BGcolor=0;
Dir=false;
yAdd=0;
}
Bubbles(float cX, float cY, float cXvel, float cYvel, float cLife)
{
x=cX;
y=cY;
xvel=cXvel;
yvel=cYvel;
life=cLife;
Color=dbRGB(250, 250, 250);
BGcolor=dbRGB(50, 50, 200);
Dir=true;
yAdd=3;
}
void create(float cX, float cY, float cXvel, float cYvel, float cLife)
{
x=cX;
y=cY;
xvel=cXvel;
yvel=cYvel;
life=cLife;
Color=dbRGB(250, 250, 250);
BGcolor=dbRGB(50, 50, 200);
Dir=true;
yAdd=3;
}
void move()
{
x+=xvel;
y-=yvel;
if (Dir==true)
{
yvel+=(yAdd++)/5;
if (yAdd>10)
Dir=false;
}
else
{
yvel-=(yAdd--)/5;
if (yAdd<6)
Dir=true;
}
life--;
}
void draw()
{
dbInk(Color, BGcolor);
dbCircle(x+1, y-1, 1);
dbCircle(x, y, 4);
}
};
class Fog: public pBase
{
public:
Fog()
{
x=0;
y=0;
life=0;
Color=0;
BGcolor=0;
xvel=0;
yvel=0;
}
Fog(float cX, float cY, float Life)
{
x=cX;
y=cY;
life=Life;
int temp=dbRND(50)+150;
Color=dbRGB(temp, temp, temp);
BGcolor=dbRGB(50, 50, 200);
xvel=0;
yvel=0;
}
void create(float cX, float cY, float Life)
{
x=cX;
y=cY;
life=Life;
int temp=dbRND(50)+150;
Color=dbRGB(temp, temp, temp);
BGcolor=dbRGB(50, 50, 200);
xvel=0;
yvel=0;
}
void move()
{
life--;
}
void draw()
{
dbInk(dbRGB(life*10, life*10, life*10), BGcolor);
dbCircle(x, y, 1);
dbCircle(x+3, y+3, 1);
dbCircle(x-3, y+3, 1);
dbCircle(x+3, y-3, 1);
dbCircle(x-3, y-3, 1);
}
};
class FWorks: public pBase
{
private:
float ox[3], oy[3];
int tick;
public:
FWorks()
{
x=0;
y=0;
xvel=0;
yvel=0;
Color=0;
BGcolor=0;
for (int j=0; j<3; j++)
{
ox[j]=0;
oy[j]=0;
}
tick=0;
}
FWorks(float cX, float cY, float Vel, float Dir, float cLife, int color)
{
x=cX;
y=cY;
xvel=Vel;
yvel=Dir;
life=cLife;
Color=color;
BGcolor=dbRGB(50, 50, 200);
ox[0]=x;
ox[1]=x;
ox[2]=x;
oy[0]=y;
oy[1]=y;
oy[2]=y;
tick=0;
}
void create(float cX, float cY, float Vel, float Dir, float cLife, int color)
{
x=cX;
y=cY;
xvel=Vel;
yvel=Dir;
life=cLife;
Color=color;
BGcolor=dbRGB(50, 50, 200);
ox[0]=x;
ox[1]=x;
ox[2]=x;
oy[0]=y;
oy[1]=y;
oy[2]=y;
tick=0;
}
void move()
{
tick++;
ox[2]=ox[1];
oy[2]=oy[1];
ox[1]=ox[0];
oy[1]=oy[0];
ox[0]=x;
oy[0]=y;
x+=xvel*(dbSin(yvel));
if (tick<15)
y+=xvel*(dbCos(yvel));
else
y+=xvel*(dbCos(yvel))+tick-15;
life--;
}
void draw()
{
dbInk(Color, BGcolor);
dbCircle(x, y, 4);
dbCircle(ox[0], oy[0], 3);
dbCircle(ox[1], oy[1], 2);
dbCircle(ox[2], oy[2], 1);
}
};
class Bounce: public pBase
{
private:
float xmin, xmax, ymin, ymax;
public:
Bounce()
{
x=0;
y=0;
xvel=0;
yvel=0;
xmin=0;
xmax=0;
ymin=0;
ymax=0;
life=0;
Color=0;
BGcolor=0;
}
Bounce(float cX, float cY, float cXvel, float cYvel, float cXmin, float cXmax, float cYmin, float cYmax, float cLife, int color)
{
x=cX;
y=cY;
xvel=cXvel;
yvel=cYvel;
xmin=cXmin;
xmax=cXmax;
ymin=cYmin;
ymax=cYmax;
life=cLife;
Color=color;
BGcolor=dbRGB(50, 50, 200);
}
void create(float cX, float cY, float cXvel, float cYvel, float cXmin, float cXmax, float cYmin, float cYmax, float cLife, int color)
{
x=cX;
y=cY;
xvel=cXvel;
yvel=cYvel;
xmin=cXmin;
xmax=cXmax;
ymin=cYmin;
ymax=cYmax;
life=cLife;
Color=color;
BGcolor=dbRGB(50, 50, 200);
}
void move()
{
x+=xvel;
y+=yvel;
if (x<xmin || x>xmax)
xvel=-xvel;
if (y<ymin || y>ymax)
yvel=-yvel;
life--;
}
void draw()
{
dbInk(Color, BGcolor);
dbCircle(x, y, 4);
}
};
class Orbit: public pBase
{
private:
float ix, iy, ticker, angle;
public:
Orbit()
{
ticker=0;
ix=0;
iy=0;
life=0;
xvel=0;
yvel=0;
Color=0;
BGcolor=0;
angle=0;
}
Orbit(float cX, float cY, float Vel, float Dis, float cAngle, float cLife, int color)
{
ticker=dbRND(360);
ix=cX;
iy=cY;
life=cLife;
xvel=Vel;
yvel=Dis;
Color=color;
angle=cAngle;
BGcolor=dbRGB(50, 50, 200);
}
void Create(float cX, float cY, float Vel, float Dis, float cAngle, float cLife, int color)
{
ticker=dbRND(360);
ix=cX;
iy=cY;
life=cLife;
xvel=Vel;
yvel=Dis;
Color=color;
angle=cAngle;
BGcolor=dbRGB(50, 50, 200);
}
void move()
{
x=ix+(dbSin(ticker)*(yvel*(100.0f/angle)));
y=iy+(dbCos(ticker)*yvel);
ticker+=xvel;
life--;
}
void draw()
{
dbInk(Color, BGcolor);
dbCircle(x, y, 3);
dbCircle(x, y, 2);
}
};
void DarkGDK ( void )
{
int total=200;
dbHideMouse();
int type=1;
bool clicked=false;
dbSyncOn ( );
dbSyncRate ( 60 );
pBase* part[PMAX];
Fire pfire[EXMAX];
Fog pfog[EXMAX];
Swarm pswarm[EXMAX];
Volcanoe pvol[EXMAX];
for (int j=0; j<PMAX; j++)
{
part[j]= new pBase();
}
while ( LoopGDK ( ) )
{
dbCLS();
for (int j=0; j<EXMAX; j++)
{
if (pfire[j].getLife()<1)
{
pfire[j].create(dbScreenWidth()-dbRND(50)-50, dbScreenHeight(), dbRND(15)+10, dbRND(15)+10);
}
else
{
pfire[j].move();
pfire[j].draw();
}
if (pfog[j].getLife()<1)
{
pfog[j].create(dbScreenWidth()-dbRND(50)-50, dbRND(50)+10, dbRND(20)+15);
}
else
{
pfog[j].move();
pfog[j].draw();
}
if (pswarm[j].getLife()<1)
{
pswarm[j].create(dbRND(50)+130, dbRND(50)+130, dbRND(20)+10, dbRND(20)+10);
}
else
{
pswarm[j].move();
pswarm[j].draw();
}
if (pvol[j].getLife()<1)
{
pvol[j].create(50, dbScreenHeight(), dbRND(10)-5, dbRND(15)+5, dbRND(15)+10);
}
else
{
pvol[j].move();
pvol[j].draw();
}
}
for (int j=0; j<total; j++)
{
if ((part[j]->getLife())<1)
{
delete part[j];
switch(type)
{
case 1:
if (dbRND(3)>2)
part[j]=new Volcanoe(dbMouseX(), dbMouseY(), (dbRND(10)-5), dbRND(15)+5, dbRND(15)+10);
else
part[j]=new pBase();
break;
case 2:
if (dbRND(3)>2)
part[j]=new Swarm(dbMouseX()+dbRND(50)-25, dbMouseY()+dbRND(50)-25, dbRND(5)+15, dbRND(25)+10);
else
part[j]=new pBase();
break;
case 3:
if (dbRND(3)>2)
part[j]=new Fire(dbMouseX()+dbRND(100)-50, dbMouseY(), dbRnd(10)+1, dbRND(25)+10);
else
part[j]=new pBase();
break;
case 4:
if (dbMouseClick()==1)
part[j]=new Explode(dbMouseX(), dbMouseY(), dbRND(20), dbRND(360), dbRND(10)+5);
else
part[j]=new pBase();
break;
case 5:
if (dbRND(3)>2)
part[j]=new Bubbles(dbMouseX(), dbMouseY(), dbRND(10)-5, dbRND(3), dbRND(15)+15);
else
part[j]=new pBase();
break;
case 6:
if (dbRND(3)>2)
part[j]=new Fog(dbMouseX()+dbRND(100)-50, dbMouseY()+dbRND(100)-50, dbRND(30)+10);
else
part[j]=new pBase();
break;
case 7:
if (dbMouseClick()==1)
{
int temp=dbRND(6);
int r, g, b;
switch(temp)
{
case 0:
r=200;
g=0;
b=0;
break;
case 1:
r=0;
g=200;
b=0;
break;
case 2:
r=0;
g=0;
b=200;
break;
case 3:
r=200;
g=200;
b=0;
break;
case 4:
r=0;
g=200;
b=200;
break;
case 5:
r=200;
g=0;
b=200;
break;
case 6:
r=200;
g=200;
b=200;
break;
}
part[j]=new FWorks(dbMouseX(), dbMouseY(), dbRND(10)+1, dbRND(360), dbRND(20)+20, dbRGB(r, g, b));
}
else
part[j]=new pBase();
break;
case 8:
if (dbRND(3)>2)
part[j]=new Bounce(dbMouseX(), dbMouseY(), dbRND(40)-20, dbRND(40)-20, 0, dbScreenWidth(), 0, dbScreenHeight(), dbRND(50)+20, dbRGB(200, 50, 0));
else
part[j]=new pBase();
break;
case 9:
if (dbRND(3)>2)
part[j]=new Orbit(dbMouseX(), dbMouseY(), dbRND(10)+1, dbRND(100)+5, dbRND(100), dbRND(50)+20, dbRGB(200, 50, 0));
else
part[j]=new pBase();
break;
}
}
else
{
part[j]->move();
part[j]->draw();
}
}
if (dbUpKey() && total<PMAX)
total++;
if (dbDownKey() && total>1)
{
delete part[(total-1)];
part[(total-1)]=new pBase();
total--;
}
if (dbRightKey() && clicked==false)
{
clicked=true;
type++;
if (type>9)
type=1;
}
if (dbLeftKey() && clicked==false)
{
clicked=true;
type--;
if (type<1)
type=9;
}
if (!dbRightKey() && !dbLeftKey())
{
clicked=false;
}
dbInk(dbRGB(255, 255, 255), dbRGB(50, 50, 200));
dbPrint("Total particles:");
dbPrint((double)total);
dbPrint("Particle Type:");
switch (type)
{
case 1:
dbPrint("Volcanoe");
break;
case 2:
dbPrint("Swarm");
break;
case 3:
dbPrint("Fire");
break;
case 4:
dbPrint("Explosion");
break;
case 5:
dbPrint("Bubbles");
break;
case 6:
dbPrint("Fog");
break;
case 7:
dbPrint("Fireworks");
break;
case 8:
dbPrint("Bouncy");
break;
case 9:
dbPrint("Orbiting");
break;
}
dbSync ( );
}
return;
}
and yeah, I use the dbCircle() command, I attached a version replacing circles with boxes. hope that works.
P.S: also forgot last time to tell you the controls.
Left/Right: change particle type
Up/Down: raise/lower particle count respectively.
sdrawkcab nettirw erutangis a