-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnemigo3.java
40 lines (38 loc) · 1.18 KB
/
Enemigo3.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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Enemigo3 here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Enemigo3 extends Actor
{
int x=5;
SimpleTimer shoot= new SimpleTimer();
int SHOT_INTERVAL = 150;
int MIN_SHOT = 1000;
int SHOT_MAX_INT= 2500;
int randShot = MIN_SHOT +Greenfoot.getRandomNumber(SHOT_MAX_INT);
/**
* Act - do whatever the Enemigo1 wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
GreenfootImage myImage = getImage();
int myNewHeight = (int)myImage.getHeight();
int myNewWidth = (int)myImage.getWidth();
myImage.scale(myNewWidth,myNewHeight);
setLocation(getX()-x, getY());
if((getX()>790)||(getX()<10))
{
x= x * -1;
}
if(shoot.millisElapsed()>MIN_SHOT + randShot)
{
getWorld().addObject(new BalaBasesDatos(),getX(), getY());
shoot.mark();
randShot = Greenfoot.getRandomNumber(SHOT_MAX_INT);
}
}
}