Advertisement
Guest User

Shooty_bird_menu

a guest
May 27th, 2014
785
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1.  
  2. class MenuState extends State {
  3. String text;
  4.  
  5. MenuState () {
  6. text = "Click to start game!";
  7. }
  8.  
  9. void draw() {
  10. text(text, 200,200);
  11. }
  12.  
  13. void logic () {
  14. if (skott == 0){
  15. currentState = new CountdownState(3, "Starting in...");
  16. skott = 1;
  17. }
  18. }
  19. }
  20.  
  21. class CountdownState extends State {
  22. int starttime;
  23. int endtime;
  24. int duration;
  25. String text;
  26.  
  27. CountdownState(int duration, String text) {
  28. starttime = millis();
  29. this.duration = duration*1000;
  30. endtime = millis()+this.duration;
  31. this.text = text;
  32. }
  33.  
  34. void logic() {
  35. if (millis() >= endtime){
  36. gameState.reset();
  37. currentState = gameState;
  38. }
  39. }
  40.  
  41. void draw() {
  42. text(text, 200,200);
  43. text(((endtime-millis())/1000)+1, 200,230);
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement