-
Notifications
You must be signed in to change notification settings - Fork 0
/
Toy.jr
89 lines (73 loc) · 1.66 KB
/
Toy.jr
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
import javax.swing.*; import java.awt.*; import java.lang.*;
abstract public class Toy implements java.io.Serializable {
////////////////////
// Class Variables
////////////////////
protected float x, y;
protected float xinc, yinc;
protected float size;
protected Color myco, mycot;
protected final int toy_id;
////////////////////
// Constructor
////////////////////
public Toy(float x, float y, float xinc, float yinc,
Color myco, Color mycot,
float size, int toy_id) {
this.x = x; this.y = y;
this.xinc = xinc; this.yinc = yinc;
this.myco = myco; this.mycot = mycot;
this.size = size;
this.toy_id = toy_id;
}
////////////////////
// MUTATORS
////////////////////
public void set(float sx, float sy, float sxinc, float syinc) {
x = sx;
y = sy;
xinc = sxinc;
yinc = syinc;
}
public void setX(float sx) {
x = sx;
}
public void setY(float sy) {
y = sy;
}
public void setXinc(float sxinc) {
xinc = sxinc;
}
public void setYinc(float syinc) {
yinc = syinc;
}
////////////////////
// ACCESSORS
////////////////////
public float getX() {
return x;
}
public float getY() {
return y;
}
public float getXinc() {
return xinc;
}
public float getYinc() {
return yinc;
}
public float getSize() {
return size;
}
public float getToyID() {
return toy_id;
}
////////////////////
// CLASS METHODS
////////////////////
abstract public op void moveToyOneUnit (int H, int W, float gravity,
float punchVal,
cap void() gameOver);
abstract public boolean isClicked (int mouse_x, int mouse_y);
abstract public void mydraw (Graphics2D g2);
}