-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRectangleChaser.java
More file actions
106 lines (98 loc) · 2.98 KB
/
Copy pathRectangleChaser.java
File metadata and controls
106 lines (98 loc) · 2.98 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
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import greenfoot.*;
/**
* Write a description of class RectangleChaser here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class RectangleChaser extends Chaser
{
/**
* Act - do whatever the RectangleChaser wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
private int hp;
private int dr;
private GreenfootImage image;
public GreenfootImage getImage() {
return image;
}
public RectangleChaser() {
image = new GreenfootImage(50, 50);
}
public int getDr() {
return dr;
}
public void setDr(int dr) {
this.dr = dr;
}
public int getHp() {
return hp;
}
public void setHp(int hp) {
this.hp = hp;
}
State small = new StateSmall();
State medium = new StateMedium();
State large = new StateLarge();
State currentState = large;
String size = currentState.setImage();
public void setCurrentState(){
//UserInfo me = UserInfo.getMyInfo();
//Welt welt = (Welt)getWorld().getObjects(Welt.class).get(0);
//if (getWorld()==null)
//{System.out.println("world is null");}
//else{
int count = ((Welt)getWorld()).getScore();
if (count<50){
this.currentState = large;
this.size = currentState.setImage();
}
else if (count>=50&&count<100){
this.currentState = medium;
this.size = currentState.setImage();
}
else if (count>=100){
this.currentState = small;
this.size = currentState.setImage();
}
//}
}
public void setChaserImage(){
if(size.equals("large"))
{
//image.fillOval(0, 0, 30, 30);
image.fillRect(0, 0, 50, 50);//bodor
image.setColor(new java.awt.Color(224, 240, 255));
image.fillRect(12, 12, 27, 27);//interior
setImage(image);
// image.fillRect(0, 0, 16, 16);
// setImage(image);
}
if(size.equals("medium"))
{
//image.fillOval(0, 0, 30, 30);
// image.fillRect(0, 0, 32, 32)
image.fillRect(0, 0, 40, 40);//bodor
image.setColor(new java.awt.Color(224, 240, 255));
image.fillRect(10, 10, 20, 20);//interior
setImage(image);
// setImage(image);
}
if(size.equals("small"))
{
//image.fillOval(0, 0, 30, 30);
image.fillRect(0, 0, 30, 30);//bodor
image.setColor(new java.awt.Color(224, 240, 255));
image.fillRect(7, 7, 16, 16);//interior
setImage(image);
// image.fillRect(0, 0, 8, 8);
// setImage(image);
}
}
public void draw() {
// create image for this actor
setCurrentState();
setChaserImage();
}
}