preform an action x times pre frame... where x can be less than 1 ?
in
Programming Questions
•
1 years ago
So I'm programming a simple "dodging bullets" game in the vein of Kenta Cho's rRootage. I have class Source, which is the source that bullets emanate from: (You can check out the whole program at my github sketchbook page (
https://github.com/yanom/yanomsketchbook) under the working title "fightergame"
Like, release 30 bullets every 60 frames or something. But also still be able to release multiple bullets per frame.
Also probably of interest is class Layer. Layer has-a Source. Layer updates every frame and currently, each Layer tells it's Source how many to shoot that frame. The Layer knows how many to shoot because of global variable difficulty (currently set to 1).
That's kinda a crappy setup there so I need a better solution for releasing bullets :D
- class Source {
int x;
int y;
float speed;
int r;
int g;
int b;
Source () {
x = 250;
y = 250;
speed = 5.0;
r=255;
g=0;
b=0;
}
Source (int inx, int iny) {
x = inx;
y = iny;
speed = 5.0;
r=255;
g=0;
b=0;
}
Source (int inx, int iny, float inspeed) {
x = inx;
y = iny;
speed = inspeed;
r=255;
g=0;
b=0;
}
Source (int inx, int iny, float inspeed, int ir, int ig, int ib) {
x = inx;
y = iny;
speed = inspeed;
r=ir;
g=ig;
b=ib;
}
void handle(ArrayList holdbullet, int numbullets, int windowSize) {
/*
if (goingRight) {
x += 6;
}
else {
x -= 6;
}
if (x<8) {
goingRight = true;
}
if (x>(windowSize-8)) {
goingRight = false;
}
*/
for (int iii=1; iii<=numbullets; iii++) {
float randX = random(-1*speed, speed);
float randY = random(-1*speed, speed);
holdbullet.add(new Bullet(x, y, 10, 10, r, g, b, randX, randY));
}
}
}
Like, release 30 bullets every 60 frames or something. But also still be able to release multiple bullets per frame.
Also probably of interest is class Layer. Layer has-a Source. Layer updates every frame and currently, each Layer tells it's Source how many to shoot that frame. The Layer knows how many to shoot because of global variable difficulty (currently set to 1).
That's kinda a crappy setup there so I need a better solution for releasing bullets :D
1