-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBalaGigante.java
executable file
·55 lines (44 loc) · 1.42 KB
/
BalaGigante.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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class BalaGigante here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class BalaGigante extends Inimigo
{
private int direcao;
public BalaGigante()
{
velocidade = 4;
}
public void act()
{
move(direcao * velocidade);
if(isTouching(Pombo.class))
{
// remove o pombo
removeTouching(Pombo.class);
Partida.musica.stop();
Greenfoot.setWorld(new MenuFase());
}
if (getX() == 0 || getX() == Geral.LARGURADATELA - 1)
{
getWorld().removeObject(this);
}else if(isTouching(Coco.class)){
removeTouching(Coco.class);
disparos--;
}
}
public void criaInimigo(){
this.setLocation((Greenfoot.getRandomNumber(2) * Geral.LARGURADATELA), 435);
direcao = Greenfoot.getRandomNumber(2);
this.setLocation((Geral.LARGURADATELA - 2) - (direcao * (Geral.LARGURADATELA - 3)), 50 + Greenfoot.getRandomNumber(280));
this.direcao = 2 * direcao - 1;
if (this.direcao < 0){
setImage("BalaGigante-esq.png");
}else{
setImage("BalaGigante-dir.png");
}
}
}