-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBrick.java
More file actions
75 lines (62 loc) · 1.05 KB
/
Brick.java
File metadata and controls
75 lines (62 loc) · 1.05 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
import java.awt.image.BufferedImage;
import java.awt.Graphics;
/*
* Levi Crider
* 2/9/22
* Legend of Zelda
*
*
*
*/
public class Brick extends Sprite{
//Location of the brick
static BufferedImage image;
//Constructors
public Brick(int locationx, int locationy) {
this.x = locationx;
this.y = locationy;
loadImage();
w = 50;
h = 50;
}
//Marshalling Methods
Brick(Json ob){
w = 50;
h = 50;
x = (int)ob.getLong("brickx");
y = (int)ob.getLong("bricky");
loadImage();
}
Json Marshal(){
Json ob = Json.newObject();
ob.add("brickx", x);
ob.add("bricky", y);
return ob;
}
@Override
public String toString()
{
return "Brick (x,y) = (" + x + ", " + y + ")";
}
@Override
void draw(Graphics g){
g.drawImage(image, x - View.scrollPositonX, y - View.scrollPositonY, null);
}
@Override
boolean update(){
return true;
}
@Override
boolean isBrick(){
return true;
}
@Override
void loadImage(){
if (image == null){
image = View.loadImage("brick.jpg");
}
}
@Override
void Collided(){
}
}