Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MenuState extends State {
- String text;
- MenuState () {
- text = "Click to start game!";
- }
- void draw() {
- text(text, 200,200);
- }
- void logic () {
- if (skott == 0){
- currentState = new CountdownState(3, "Starting in...");
- skott = 1;
- }
- }
- }
- class CountdownState extends State {
- int starttime;
- int endtime;
- int duration;
- String text;
- CountdownState(int duration, String text) {
- starttime = millis();
- this.duration = duration*1000;
- endtime = millis()+this.duration;
- this.text = text;
- }
- void logic() {
- if (millis() >= endtime){
- gameState.reset();
- currentState = gameState;
- }
- }
- void draw() {
- text(text, 200,200);
- text(((endtime-millis())/1000)+1, 200,230);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement