I am making a game in which I am implementing a particle system. I used a similar method as bullet creation to generate the particles, but when I try to add the functions to the game, the LCD just comes up blank. Here is the code:
- Code: Select all
void initParticles(){
if(crashed){
for(byte thisParticle = 0; thisParticle < NUMPARTS; thisParticle++){
int randX = random(-8,8);
int randSelect = random(1,25);
if(!particleActive[thisParticle]){
if(randSelect == 2){
particleActive[thisParticle] = true;
particleLife[thisParticle] = random(10,40);
particleX[thisParticle] = playerX+randX;
particleY[thisParticle] = playerY;
break;
}
}
}
}
}
void moveParticles(int dir, int sp){
for(byte thisParticle = 0; thisParticle < NUMPARTS; thisParticle++){
moveXYDS(particleX[thisParticle],particleY[thisParticle],dir,sp);
if(particleLife[thisParticle] == 0){
particleActive[thisParticle] = false;
}
}
}
void drawParticles(){
for(byte thisParticle = 0; thisParticle < NUMPARTS; thisParticle++){
if(particleActive[thisParticle]){
int x, y;
if(screenCoord(particleX[thisParticle], particleY[thisParticle], x, y)){
gb.display.fillRect(x, y,2,2);
}
}
}
}