-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNave.java
92 lines (68 loc) · 1.75 KB
/
Nave.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
import java.awt.*;
public class Nave extends ObjetoMovil {
private int lives, speed, height, width;
private Misil misil;
public Nave(Color color, int posX, int posY, Misil misil2) {
super(color, posX, posY);
lives = 3;
height = 100;
width = 100;
speed = 10;
misil = new Misil(Color.BLACK, posX, posY);
}
public void move(int tecla, int lD) {
if (tecla == 37) {//left
if ( (posX - speed > 0)) {
posX -= speed;
}
}
if (tecla == 39) {//right
if (((posX + speed + width) < lD)) {
posX += speed;
}
}
}
public void returnBala() {
misil.returnBala(posX, posY);
}
public Misil getMisil() {
return misil;
}
public void setMisil(Misil misil) {
this.misil = misil;
}
public int getLives() {
return lives;
}
public void setLives(int lives) {
this.lives = lives;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getSpeed() {
return speed;
}
public void setSpeed(int speed) {
this.speed = speed;
}
public void paint(Graphics graphics) {
graphics.setColor(color);
graphics.fillRect(posX, posY, width, height);
if(misil.isActiva()) {
misil.paint(graphics);
}
}
public boolean colision() {
return false;
}
}