-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGame.java
79 lines (72 loc) · 2.46 KB
/
Game.java
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package com.example.manju.shapes;
import java.util.LinkedList;
//Model
public class Game {
private Circle circle;
private Square square;
public static LinkedList<Circle> circlelist = new LinkedList<Circle>();
public static LinkedList<Square> squarelist = new LinkedList<Square>();
public Game(){
circle = new Circle(100, 200, 50);
circlelist.add(circle);
circle = new Circle(150, 250, 50);
circlelist.add(circle);
circle = new Circle(200, 450, 100);
circlelist.add(circle);
circle = new Circle(50, 450, 70);
circlelist.add(circle);
circle = new Circle(400, 50, 150);
circlelist.add(circle);
circle = new Circle(700, 500, 20);
circlelist.add(circle);
circle = new Circle(400, 50, 150);
circlelist.add(circle);
circle = new Circle(700, 700, 250);
circlelist.add(circle);
circle = new Circle(500, 700, 120);
circlelist.add(circle);
circle = new Circle(600, 900, 100);
circlelist.add(circle);
square = new Square(100,100,150,150);
squarelist.add(square);
square = new Square(500,500,1000,1000);
squarelist.add(square);
square = new Square(50,50,100,100);
squarelist.add(square);
square = new Square(200,200,250,250);
squarelist.add(square);
square = new Square(300,300,175,175);
squarelist.add(square);
square = new Square(100,100,275,275);
squarelist.add(square);
square = new Square(850,850,975,975);
squarelist.add(square);
}
public void update() {
for (int i = 0; i < circlelist.size(); i++) {
if (i == 0 || i==5) {
circlelist.get(i).moveEast();
} else if(i==1 || i==6) {
circlelist.get(i).moveNorth();
}else{
circlelist.get(i).moveWest();
}
if(i==4 || i==9){
circlelist.get(i).moveSouth();
}
}
for (int i = 0; i < squarelist.size(); i++) {
if(i==2 || i==5){
squarelist.get(i).moveNorth();
}else {
squarelist.get(i).moveSouth();
}
if(i==3){
squarelist.get(i).moveEast();
}
if(i==4){
squarelist.get(i).moveWest();
}
}
}
}