-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAgentes.java
More file actions
91 lines (78 loc) · 2.5 KB
/
Copy pathAgentes.java
File metadata and controls
91 lines (78 loc) · 2.5 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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Agentes here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Agentes extends Enemigo
{
/**
* Act - do whatever the Agentes wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
move(5);
World m=getWorld();
if(getX()>=m.getWidth()-5||getX()<=5)
{
turn(180);
if(Greenfoot.getRandomNumber(100)<90)
{
turn(Greenfoot.getRandomNumber(90-45));
}
}
if(getY()>=m.getHeight()-5||getY()<=5)
{
turn(180);
if(Greenfoot.getRandomNumber(100)<90)
{
turn(Greenfoot.getRandomNumber(90-45));
}
}
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));
}
}
Actor Shot;
Shot=getOneObjectAtOffset(0,0,Shot.class);
{
if(Shot!=null)
{
Desierto esp=(Desierto)getWorld();
getWorld().removeObject(Shot);
esp.puntos.incrementar();
if(esp.puntos.obtenerPuntos()>15)
{
getWorld().setBackground(new GreenfootImage("bathroom-tile.jpg"));
creaEnemigo(1);
bNivel=1;
}
//esp.creaAlgo(1);
getWorld().removeObject(this);
}
}
}
public void creaEnemigo(int numeros)
{
int i;
for( i=0;i<numeros;i++)
{
Trump a=new Trump();
getWorld().addObject(a,850,400);
}
}
}