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!


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 53 54 55 56 | 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()); } } |
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 53 54 55 56 | 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()); } } |