-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFireball.java
More file actions
52 lines (46 loc) · 1.03 KB
/
Fireball.java
File metadata and controls
52 lines (46 loc) · 1.03 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
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.io.IOException;
import java.io.File;
import java.awt.Graphics;
public class Fireball extends Sprite
{
int x,y;
int width, height;
int bounceCount, frameCounter;
double vert_vel;
static BufferedImage fireBall_image=null;
Fireball(int x, int y)
{
this.x=x;
this.y=y;
width=50;
height=50;
super.type="fireball";
if (fireBall_image==null)
{
fireBall_image=View.loadImage("fireball.png");
}
}
void update()
{
if (y>=390 || (frameCounter>1 && frameCounter<6))
{
frameCounter++;
y=390;
vert_vel-=2;
y+=vert_vel;
}
else
{
frameCounter=0;
vert_vel+=1;
y+=vert_vel;
}
x+=3;
}
void drawYourself(Graphics g)
{
g.drawImage(fireBall_image,x,y,null);
}
}