How could I implement something in my BirdyWorld, so that the game doesnt start until a countdown is met. Counting down from 3... so 3, 2 , 1 (and then game starts)?
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class birdWorld here.
*
* Image Citation:
* Indonesia, bevoilln. “Shady Forest Game Background.” Dribbble, 8 Jan. 2018, dribbble.com/shots/3200773-Shady-Forest-Game-Background.
*
* @author Miguel Valdez
* @version version 1
*/
public class BirdyWorld extends World
{
Counter counter = new Counter();
Blocker blocker = new Blocker();
int obstacleCounter = 0;
int birdCounter = 0;
int gap = 185;
public int score = 0;
int firstObstacle = 330;
static int xDimension = 800;
static int yDimension = 600;
/**
* Constructor for objects of class BirdWorld.
*
*/
public BirdyWorld()
{
// Create a new world with 800x600 cells with a cell size of 1x1 pixels.
super(xDimension, yDimension, 1, false);
setPaintOrder (GameOver.class, Counter.class, Obstacle.class, Obstacle2.class, Birdy.class);
//adds the counter;
addObject (counter, xDimension/2, yDimension/15 );
counter.scoreCount(0);
//adds bird to the world.
addObject (new Birdy(), xDimension/8 ,(int)(0.5*getHeight()));
//prevents bird from flying out of visual view.
addObject (new Blocker(), xDimension/2, yDimension/-6);
}
public void genObstacles()
{
int random = Greenfoot.getRandomNumber(getHeight() * 2/3);
Obstacle greenTube = new Obstacle();
Obstacle2 greenTube2 = new Obstacle2();
addObject(greenTube, getWidth() + greenTube.getImage().getWidth()/2, getHeight() + greenTube.getImage().getHeight()/2 - 50 - random); // creates random obstacles.
addObject(greenTube2, greenTube.getX(), greenTube.getY() - greenTube2.getImage().getHeight() - gap); //aligns top obstacle to the one in the bottom.
}
public void act()
{
obstacleCounter++;
if (obstacleCounter % 100 == 0)
{
genObstacles();
}
if (obstacleCounter >= firstObstacle)
{
if (birdCounter % 100 == 0)
{
score++;
counter.scoreCount(score);
Greenfoot.playSound("ScoringNoise.mp3");
}
birdCounter++;
}
}
}
