-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFireball.java
More file actions
56 lines (50 loc) · 1.14 KB
/
Fireball.java
File metadata and controls
56 lines (50 loc) · 1.14 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
//----------------------------------------------------------------------
// Author: Micheal Oyenekan
// Date : 10/23/2020 (Completed)
// File : Fireball.java
//----------------------------------------------------------------------
import java.awt.image.BufferedImage;
import java.awt.Graphics;
import java.io.File;
import javax.imageio.ImageIO;
public class Fireball extends Sprite
{
static BufferedImage image;
Model model;
double vert_vel, speed;
public Fireball(int x, int y, Model m)
{
this.x = x;
this.y = y;
w = 47;
h = 47;
this.model = m;
vert_vel = 6.0;
speed = 10.0;
if(image == null)
image = View.loadImage("fireball.png");
}
@Override
boolean isFireball()
{
return true;
}
void update()
{
this.x += speed;
this.y += vert_vel;
if (this.y >= 400 - h)
{
vert_vel *= -1;
}
if(this.y < 0)
{
this.y = 0;
vert_vel += 6.0;
}
}
void draw(Graphics g)
{
g.drawImage(image, x - model.mario.x + model.mario.marioOffset, y, null);
}
}