-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMoedas.java
52 lines (42 loc) · 1.09 KB
/
Moedas.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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Moedas here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Moedas extends Actor
{
public int proximoPasso = 2;
public static final int TAXA_DE_ATUALIZACAO = 6;
public void act()
{
rodaMoeda();
movimentaMoeda();
sairCena();
}
/*
* Faz com que a moeda saia de cena
*/
public void sairCena(){
if (getX() <= 0){
getWorld().removeObject(this);
}
}
private void movimentaMoeda(){
move(MyWorld.TAMANHO_DO_QUADRO * -1);
}
private void rodaMoeda(){
setImage(new GreenfootImage("moedas/coin"+proximoPasso+".png"));
if( possoAtualizar()){
proximoPasso++;
}
if(proximoPasso > 6){
proximoPasso = 1;
}
}
private boolean possoAtualizar(){
MyWorld myworld = (MyWorld) getWorld();
return (myworld.cicloAtual() % TAXA_DE_ATUALIZACAO) == 0 ;
}
}