-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrump.java
More file actions
100 lines (78 loc) · 2.42 KB
/
Copy pathTrump.java
File metadata and controls
100 lines (78 loc) · 2.42 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
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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Trump here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Trump extends Enemigo
{
/**
* Act - do whatever the Trump wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
private int aza;
private int vidas;
public Trump()
{
vidas=5;
}
public void act()
{
move(5);
World m=getWorld();
if(getX()>=m.getWidth()-5||getX()<=5)
{
turn(180);
}
Actor Pena;
Pena=getOneObjectAtOffset(0,0,Pena.class);
if(Pena!=null)
{
Desierto esp=(Desierto)getWorld();
getWorld().removeObject(Pena);
esp.vidas.decrementar();
//getWorld().removeObject(this);
esp.objLife.Disminuir();
getWorld().addObject(new Pena(),100,400);
if(esp.vidas.obtenerPuntos()==0)
{
GameOver g=new GameOver();
getWorld().addObject(g,((getWorld().getWidth()/2)+30),((getWorld().getHeight()/2)+150));
}
}
setShot(3);
Muere();
if(vidas==0)
{
Ganar ga=new Ganar();
getWorld().addObject(ga,((getWorld().getWidth()/2)+30),((getWorld().getHeight()/2)+150));
getWorld().removeObject(this);
Greenfoot.stop();
}
}
public void setShot(int direction)
{
aza=Greenfoot.getRandomNumber(220);
if(aza<=3)
{
ShotT s1= new ShotT(direction);
getWorld().addObject(s1,getX(),getY());
}
}
public void Muere()
{
Actor Shot;
Shot=getOneObjectAtOffset(0,0,Shot.class);
{
if(Shot!=null)
{
Desierto esp=(Desierto)getWorld();
getWorld().removeObject(Shot);
esp.puntos.incrementar();
vidas--;
//esp.creaAlgo(1);
}
}
}
}