SHOW:
|
|
- or go back to the newest paste.
1 | public void play() | |
2 | { | |
3 | while(!player.isDefeated() && !opponent.isDefeated()) | |
4 | { | |
5 | player clicks location | |
6 | Gui tells boardhandler to change marker | |
7 | if(transfer(loc).equals("red") || transfer(loc).equals("white")) | |
8 | prompt user to click on another spot | |
9 | opponent.putMarker(loc);//boardhandler changes marker on opponentboard | |
10 | boardhandler tells gui to update graphics([r]c = red or white)//(oppboard) | |
11 | int r = (int) 10 * Math.random(); | |
12 | int c = (int) 10 * Math.random(); | |
13 | Location temp = boardhandler plays for opponent- chooses square | |
14 | //Location loc1 = transfer(temp);//keep reference to last hit | |
15 | if(transfer(temp.equals("red"))) | |
16 | { | |
17 | int d = 360 / (int)(4 * Math.random() + 1); | |
18 | temp.getLocationToward(d); | |
19 | if(temp2.equals("red")) | |
20 | temp = new location; | |
21 | } | |
22 | else if(hadn't looked in all 4 directions) | |
23 | randomly select another adjacent location | |
24 | } |