-
Notifications
You must be signed in to change notification settings - Fork 0
/
NME3.java
117 lines (86 loc) · 2.23 KB
/
NME3.java
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.Random;
public class NME3 extends Rectangle {
/**
*
*/
private static final long serialVersionUID = 1L;
int dx, dy;
int type, type2;
double theta = 0;
double dtheta = 2*Math.PI/90;
double theta2 = Math.PI;
double ddtheta = Math.PI/50;
Color c;
Boolean startPath = false;
int lives = 3;
Particle[] particle;
static ArrayList<Lasers> Laserz;
int counter = 0;
Warning warn;
public NME3() {
Random r = new Random();
warn = new Warning();
type = 1;
//type2 = r.nextInt(2);
this.setSize(40,40);
Laserz = new ArrayList<Lasers>();
c = Color.MAGENTA;
int yLoc = r.nextInt(500)+100;
this.setLocation(1000,yLoc);
dx = -4;
//Lasersz = new ArrayList<Lasers>();
}
public void reset(Graphics2D win) {
//int yLoc = r.nextInt(500)+100;
this.setLocation(1000,100);
}
public void move(Graphics2D win, Ship ship) {
if (GameDriverV4.Keys[KeyEvent.VK_SPACE]) {
win.fill(this);
}
if (startPath == false && this.getX() < 999 && type ==1) {
startPath = true;
}
else if (startPath == true){
Point center = new Point(900,350);
int radius = 200;
this.theta2 += this.ddtheta;
int yLoc = (int) (center.y - radius*Math.sin(this.theta2));
int xLoc = (int) (center.x - radius*Math.cos(this.theta2));
this.setLocation(xLoc, yLoc);
}
this.translate(dx, 0);
if (type==1){
win.drawImage(Main.shocker.loop(), null, this.x, this.y);
}
if (type==1) {
counter++;
counter%=20;
if (counter==0) {
Lasers laze1 = new Lasers((int)this.getMaxX(), (int)this.getCenterY());
Laserz.add(laze1);
}
for (Lasers l1 : Laserz) {
l1.nme3gun(win);
}
for (int j = 0; j < Laserz.size(); j++) {
Lasers bullets = Laserz.get(j);
if (bullets!=null) {
if (bullets.intersects(ship)){
Laserz.remove(j);
j--;
ship.lives--;
warn.hpflash(win);
ship.hpbar-=2;
}
}
}
}
}
}