-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBoss1.java
More file actions
68 lines (50 loc) · 1.27 KB
/
Boss1.java
File metadata and controls
68 lines (50 loc) · 1.27 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
package com.tutorial.main;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.util.Random;
public class Boss1 extends GameObject
{
private Handler handler;
Random r = new Random();
private int timer = 80;
private int timer2 = 50;
public Boss1(int x, int y, ID id, Handler handler)
{
super(x, y, id);
this.handler = handler;
velX = 0;
velY = 2;
}
public Rectangle getBounds()
{
return new Rectangle((int)x, (int)y, 96, 96);
}
public void tick()
{
x += velX;
y += velY;
if(timer <= 0) velY = 0;
else timer--;
if(timer <= 0) timer2--;
if(timer2 <= 0)
{
if(velX== 0) velX = 2;
if(velX > 0)
velX += 0.0085f;
else if(velX < 0)
velX -= 0.0085f;
velX = Game.clamp(velX, -10, 10);
int spawn = r.nextInt(10);
if(spawn == 0) handler.addObject(new Boss1Bullet((int)x+48, (int)y+48, ID.BasicEnemy, handler));
}
//if(y <= 0 || y >= Game.HEIGHT - 32) velY *= -1;
if(x <= 0 || x >= Game.WIDTH - 96) velX *= -1;
handler.addObject(new Trail((int)x, (int)y, ID.Trail, Color.red, 96, 96, 1f, handler));
}
public void render(Graphics g)
{
g.setColor(Color.red);
g.fillRect((int)x, (int)y, 96, 96);
}
}