-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGoomba.java
More file actions
76 lines (67 loc) · 1.7 KB
/
Copy pathGoomba.java
File metadata and controls
76 lines (67 loc) · 1.7 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
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.io.IOException;
import java.io.File;
import java.awt.Graphics;
public class Goomba extends Sprite
{
int x;
int y;
int width;
int height;
int moveAmount=5;
int currentImage=0;
int frameCounter=0;
boolean imHit=false;
static BufferedImage [] goomba_images=null;
Goomba (int x, int y)
{
this.x=x;
this.y=y;
if (goomba_images==null)
{
goomba_images=new BufferedImage[2];
}
goomba_images[0]=View.loadImage("goomba.png");
goomba_images[1]=View.loadImage("goomba_fire.png");
}
public Goomba(Json ob)
{
x=(int)ob.getLong("x");
y=(int)ob.getLong("y");
width=100;
height=200;
super.type="goomba";
if (goomba_images==null)
{
goomba_images=new BufferedImage[2];
}
goomba_images[0]=View.loadImage("goomba.png");
goomba_images[1]=View.loadImage("goomba_fire.png");
}
void drawYourself(Graphics g)
{
g.drawImage(goomba_images[currentImage],x-super.scrollPos,y,null);
x+=moveAmount;
}
void update()
{
if (imHit)
{
frameCounter++;
}
}
boolean fireballCollision(Sprite sprite)
{
Fireball fireball= (Fireball) sprite;
if (fireball.x+fireball.width+2>x && (fireball.x+fireball.width+2)<(x+width+60))
{
System.out.println("Now im right here");
currentImage=1;
imHit=true;
frameCounter++;
return true;
}
return false;
}
}