-
-
Save NickCarneiro/1990451 to your computer and use it in GitHub Desktop.
Fixed compile bugs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package game; | |
import java.util.ArrayList; | |
public class RunningGame extends Minigame { | |
private int correct = 2; | |
private IconEntity arrow_left; | |
private IconEntity arrow_right; | |
private int selected = 0; | |
private int leftcount = 0; | |
private int rightcount = 0; | |
private long start_time = 0; | |
private boolean game_started = false; | |
public RunningGame(ArrayList<Entity> entities, ArrayList<Entity> removeList, Engine engine) { | |
super(entities, removeList, engine); | |
} | |
public void setup(){ | |
System.out.println("Setting up RunningGame"); | |
Entity frame = new FrameEntity(engine,"sprites/background_coffee.jpg", 0, 0); | |
entities.add(frame); | |
arrow_right = new IconEntity(engine,"sprites/right_arrow.png", 5, 5); | |
entities.add(arrow_right); | |
arrow_left = new IconEntity(engine,"sprites/left_arrow.png", 5, 5); | |
entities.add(arrow_left); | |
} | |
public void logic(){ | |
if(game_started == false){ | |
if(engine.leftPressed == true){ | |
System.out.println("Starting RunningGame!"); | |
game_started = true; | |
start_time = System.currentTimeMillis(); | |
} | |
} else { | |
//we're running | |
if(engine.leftPressed){ | |
leftcount++; | |
System.out.print(arrow_left); | |
} | |
if(engine.rightPressed){ | |
rightcount++; | |
System.out.print(arrow_right); | |
} | |
//check if we're done | |
long delta = System.currentTimeMillis() - start_time; | |
if(delta > 5000){ | |
complete = true; | |
if(leftcount + rightcount > 10){ | |
//you win | |
result = true; | |
} else { | |
//you lose | |
result = false; | |
} | |
System.out.println(leftcount + " " + rightcount + " "); | |
} | |
} | |
long current_time = System.currentTimeMillis(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment