I want that Bowser shoots to the left side randomly, but how do I make this?
His coordinates are (x = 700, y = 200).
PLEASE HELP ME!
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Bowser here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Bowser extends Actor
{ private GifImage g = new GifImage("Bowserreadytofightleft.gif");
private GifImage f = new GifImage("Bowserstarving.gif");
private int minShotDelay = 40;
private int maxShotDelay = 160;
private int shotTimer = minShotDelay;
/**
* Act - do whatever the Bowser wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
standard();
hitted();
shootRandomly();
if (shotTimer == 0)
{
getWorld().addObject(new Fireballs(), getX(), getY());
shotTimer = minShotDelay+Greenfoot.getRandomNumber(1+maxShotDelay-minShotDelay);
}
else shotTimer--;
}
public void standard()
{if(!isTouching(Fireball.class))
{
this.setImage(g.getCurrentImage());
}
}
public void hitted()
{if(isTouching(Fireball.class))
{
this.setImage(f.getCurrentImage());
HealthBar.health--;
}
}
public void shootRandomly()
{
Fireballs fireballs = new Fireballs();
getWorld().addObject( fireballs, getX(), getY());
}
}import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Bowser here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Bowser extends Actor
{ private GifImage g = new GifImage("Bowserreadytofightleft.gif");
private GifImage f = new GifImage("Bowserstarving.gif");
private int minShotDelay = 40;
private int maxShotDelay = 160;
private int shotTimer = minShotDelay;
/**
* Act - do whatever the Bowser wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
standard();
hitted();
shootRandomly();
if (shotTimer == 0)
{
getWorld().addObject(new Fireballs(), getX(), getY());
shotTimer = minShotDelay+Greenfoot.getRandomNumber(1+maxShotDelay-minShotDelay);
}
else shotTimer--;
}
public void standard()
{if(!isTouching(Fireball.class))
{
this.setImage(g.getCurrentImage());
}
}
public void hitted()
{if(isTouching(Fireball.class))
{
this.setImage(f.getCurrentImage());
HealthBar.health--;
}
}
public void shootRandomly()
{
Fireballs fireballs = new Fireballs();
getWorld().addObject( fireballs, getX(), getY());
}
}