-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakemake
95 lines (79 loc) · 2.22 KB
/
Makemake
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
//implementacion del planeta Makemake
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Makemake here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Makemake extends ActorBase
{
/**
* {@value #COMBUSTIBLE_CONTENIDO}
*/
private static final int COMBUSTIBLE_CONTENIDO = 100;
private double ESCALA_X = 0.9;
private double ESCALA_Y = 0.9;
protected int vida;
public Makemake() {
this.vida = 51 + (int) (Math.random() * 50);
}
public Makemake(int vida) {
this.vida = vida;
}
/**
* Establece la imagen con la escala definida
*/
@Override
protected void actualizarImagen() {
int tamCelda = getWorld().getCellSize();
int ancho = Math.max(30, (tamCelda * vida) / obtenerTamañoMaximo());
GreenfootImage image = getImage();
if (this.vida <= 0)
image.setTransparency(0);
image.scale(ancho, ancho);
setImage(image);
GreenfootImage Makemake = getImage();
image.scale((int) (tamCelda * ESCALA_X), (int) (tamCelda * ESCALA_Y));
setImage(image);
}
/**
* post: el Item desaparece del mundo
*
* @return la cantidad de combustible que el Item proporciona
*/
public int serRecogido() {
getWorld().removeObject(this);
Greenfoot.delay(20);
return COMBUSTIBLE_CONTENIDO;
}
public void recibirDañoDe(Atacante atacante) {
int daño = atacante.obtenerDaño();
this.vida -= daño;
actualizarImagen();
explotar();
if (this.vida <= 0) {
getWorld().removeObject(this);
}
}
protected void explotar() {
Explosion x = new Explosion();
getWorld().addObject(x, this.getX(), getY());
x.animar();
getWorld().removeObject(x);
}
//posiciones
public int getPosicionXBarrera(){
return this.getX();
}
public int getPosicionYBarrera(){
return this.getY();
}
@Override
protected void addedToWorld(World world) {
actualizarImagen();
}
protected int obtenerTamañoMaximo() {
return 100;
}
}