-
Notifications
You must be signed in to change notification settings - Fork 6
/
Mushroom.java
executable file
·50 lines (43 loc) · 1.6 KB
/
Mushroom.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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Mushroom here.
*
* @author (João Paulo S. Abreu ([email protected]), Mateus C. Moura
* ([email protected]), Rafael P. Casaes Sampaio
* ([email protected]),
* Uanderson S. Celestino ([email protected]), Lílian T. de
* Sousa ([email protected]), Jefferson Aimon de B. Silva
* ([email protected]))
* @version (a version number or a date)
*/
public class Mushroom extends AllObjects {
// Contrutor do Mushroom
public Mushroom() {
setImage("cogumelo.png");
scaleImage(2, 2);
}
/**
* Act - do whatever the Mushroom wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
@Override
public void act() {
// metodo para o cogumelo cair a cada "velDown" determinado
fall();
removeMushroom();
// Add your action code here.
}
public void removeMushroom() {
// condicional para remover objeto na posição >= 499px
if (getY() >= 499) {
((Florest) getWorld()).removeObject(this);
} else if (isTouching(Parrot.class)) {
// metodo para chamar midia de som
Greenfoot.playSound("sounds/eat.mp3");
// serve para instanciar a variavel ponto da classe Score
Score.add();
// se o papagaio tocar no cogumeloremove o mesmo
((Florest) getWorld()).removeObject(this);
}
}
}