-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRunMe.java
More file actions
49 lines (38 loc) · 1.13 KB
/
RunMe.java
File metadata and controls
49 lines (38 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import processing.core.*;
public class RunMe extends PApplet {
int c;
TurnOffTheLights game;
Display display;
public void setup() {
size(640, 550); // set the size of the screen.
// Create a game object
game = new TurnOffTheLights(5, 5);
// Create the display
// parameters: (10,10) is upper left of display
// (300, 300) is the width and height
display = new Display(this, 10, 10, 400, 400);
display.setColor(1, 0xFF3399FF); // SET COLORS FOR PLAYER 1 & 2
display.setColor(2, 0xFF888888);
// You can use images instead if you'd like.
// d.setImage(1, "c:/data/ball.jpg");
// d.setImage(2, "c:/data/cone.jpg");
display.initializeWithGame(game);
c = 0;
}
@Override
public void draw() {
background(200);
display.drawGrid(game.getGrid()); // display the game
}
public void mouseClicked() {
Location loc = display.gridLocationAt(mouseX, mouseY);
game.move(loc.getRow(), loc.getCol());
if (game.isGameOver()) {
System.out.println("You win!");
}
}
// main method to launch this Processing sketch from computer
public static void main(String[] args) {
PApplet.main(new String[] { "RunMe" });
}
}