Re: developing a kind of radar?

For BGT, I wrote a clock class that takes care of the timer shenanigans. All you need to specify is how much time should pass between the start of each frame.
A main function might look like this:

void main() {
clock fps(50); // The constructor takes frames/second as a parameter and determines the delay for you.
double frametime=fps.delay; // This is the target time that passes between frames.

show_game_window("Game with frames");
while(true) {
keycheck();
step_game(frametime);
update_other_things(frametime);

fps.tick();
}
}

In practice, I'd include a method (I usually call it step) that takes the amount of time that passes as a parameter, for each class that needs time-sensitive updating. Enemies and radars both fall into this category. You could use an interface for tickable objects, but I don't see the need for it most of the time.

If the step/tick/update method is the part that's throwing you off, odds are that most classes like this will include this sort of thing:

class TimedObject {
double counter=0.0;

/* [...] */

void step(double dt) {
counter-=dt;
if(counter<=0.0) {
// Time's up: do whatever needs doing. Update your radar angle, for example.

// Reset the counter. As an example:
this.counter=1000.0; // Assuming milliseconds.
}
}
}
_______________________________________________
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ian Reed via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Dranelement via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Dranelement via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Dranelement via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Dranelement via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Dranelement via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Dranelement via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Dranelement via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector

Reply via email to