Re: Justice League Assemble questions
Basically:
class stepper {
int state;
double counter;
stepper() {
state=0;
counter=0.0;
}
bool setState(int s) { // Check for necessary conditions. state=s; // Figure out what to do for each state. I would normally use objects for this, but for JLA I just used enormous if-else chains. The simplest example, I guess: counter=0.25; // We assume there is a global variable called pool. pool.play_stationary("startsound.wav", false); // Well, you should position it instead. return state==s; // In case it didn't take somewhere. } void step(double dt) { if(counter>0.0) { counter-=dt; if(counter<=0.0) { counter=0.0; // Figure out what to do when a state ends. // You could play a sound here, or pick a different state to go to, etc. setState(0); }// 0 from above. }// descending. else if(counter<0.0) { counter+=dt; if(counter>=0.0) { counter=0.0; // Etc. setState(0); }// 0 from below }// ascending // Anything you want to do at all times. If you had a velocity variable, you might try to move the character here. } } sound_pool pool; void main() { stepper player; show_game_window("Look at it go...."); while(true) { stepper.step(0.005); if(key_pressed(KEY_F4) and (key_down(KEY_LMENU) or key_down(KEY_RMENU)) exit(); else if(key_pressed(KEY_C)) show_game_window("Counter: " + player.counter); else if(key_pressed(KEY_S)) show_game_window("State: " + player.state); else if(key_pressed(KEY_SPACE)) player.setState(1); wait(5); } }
_______________________________________________ Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector