i need to know how to brodcast to other actors
if(getWorld()!=null && getWorld().getObjects(hackepalyz.class).size()> 0)
{
Actor user=(Actor)getWorld().getObjects(hackeplayz.class).get(0);
user.move(72726728283);
}
void prepare2(){
spawnTimer = (spawnTimer+1)%720;
if (spawnTimer%45 == 0){
switch(getRandomNumber(0,2))
{
default:
break;
case 0:
getWorld().addObject(new pipe_up(), 280, 3);// want to do brod cast command after this line to the other
//pipe
break;
case 1:
getWorld(). addObject(new pipe_up(), 280, 65);
break;
case 2:
getWorld().addObject(new pipe_up(), 280, 33);
break;
}
}
}import greenfoot.*;
/**
* Write a description of class pipe_up here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class pipe_up extends Actor
{
/**
* Act - do whatever the pipe_up wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
private int spawnTimer;
public void act()
{
kill_da_bird();
iamcommingforu();
prepare2();
}
void kill_da_bird(){
Actor bird = getOneIntersectingObject(bird.class);
if(bird != null){
getWorld().removeObject(bird);
}
}
void iamcommingforu(){
move(-5);
}
void prepare2(){
spawnTimer = (spawnTimer+1)%720;
if (spawnTimer%45 == 0){
switch(getRandomNumber(0,2))
{
default:
break;
case 0:
getWorld().addObject(new pipe_up(), 280, 3);// want to do brod cast command after this line to the other
//pipe
break;
case 1:
getWorld(). addObject(new pipe_up(), 280, 65);
break;
case 2:
getWorld().addObject(new pipe_up(), 280, 33);
break;
}
}
}
private int getRandomNumber(int start, int range)
{
return start + (int)Greenfoot.getRandomNumber(range-start+1);
}
}
import greenfoot.*;
/**
* Write a description of class flappyworld here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class flappyworld extends World
{
public static int Score= 0;
flappyworld thisgame;
private int spawnTimer;
/**
* Constructor for objects of class flappyworld.
*
*/
public flappyworld()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(600, 400, 1);
Score= 0;
prepare();
}
public void act()
{
showText("Score: " + Score, 50, 25);
prepare2();
}
void prepare2(){
spawnTimer = (spawnTimer+1)%720;
if (spawnTimer%45 == 0){
switch(getRandomNumber(0,2))
{
default:
break;
case 0:
getworld().addObject(new pipe_up(), 280, 3);// want to do brod cast command after this line to the other
//pipe
break;
case 1:
getWorld(). addObject(new pipe_up(), 280, 65);
break;
case 2:
getWorld().addObject(new pipe_up(), 280, 33);
break;
}
}
}
private int getRandomNumber(int start, int range)
{
return start + (int)Greenfoot.getRandomNumber(range-start+1);
}
/**
* Prepare the world for the start of the program. That is: create the initial
* objects and add them to the world.
*/
private void prepare()
{
bird bird = new bird();
addObject(bird, 66, 211);
bird.setLocation(61, 193);
line line = new line();
addObject(line, 19, 199);
line.setLocation(16, 194);
line.setLocation(16, 194);
line.setLocation(16, 194);
line.setLocation(16, 194);
line.setLocation(16, 194);
line.setLocation(16, 194);
line.setLocation(16, 194);
line.setLocation(16, 194);
line.setLocation(16, 194);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(7, 190);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(4, 221);
line.setLocation(0, 197);
line.setLocation(0, 197);
line.setLocation(0, 197);
line.setLocation(0, 197);
line.setLocation(0, 197);
line.setLocation(0, 197);
line.setLocation(0, 197);
line.setLocation(0, 197);
line.setLocation(0, 197);
line.setLocation(0, 197);
line.setLocation(0, 197);
line.setLocation(0, 197);
line.setLocation(0, 197);
line.setLocation(0, 197);
line.setLocation(0, 197);
line.setLocation(0, 197);
line.setLocation(0, 197);
line.setLocation(0, 197);
line.setLocation(0, 197);
line.setLocation(0, 197);
line.setLocation(0, 197);
line.setLocation(0, 197);
line.setLocation(0, 197);
line.setLocation(0, 197);
line.setLocation(0, 197);
line.setLocation(0, 197);
line.setLocation(0, 197);
line.setLocation(0, 197);
}
}