This is what I have but it doesnt really work because all of the movements are really fast I want the actor to make random movements across a 400 pixel wide Y axis without changing the X axis variable, is this possible?
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 | private GreenfootImage Change = new GreenfootImage( "Transparent Jordan mouth opened.png" ); /** * Act - do whatever the Jordan wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public boolean firing2 = MyWorld.firing; public int ranTurn = 0 ; public String[] pM = { "+" , "-" }; public void act() { if (JumpPortal.level2) { getWorld().addObject( this , 200 , 575 ); ranTurn++; if (ranTurn <= Greenfoot.getRandomNumber( 80 )) { setLocation(getX(), getY() - 3 ); } if (ranTurn > Greenfoot.getRandomNumber( 80 ) + 80 ) { setLocation(getX(), getY() + 3 ); } else if ( ranTurn > 50 ) { ranTurn = 0 ; } else if (getY() == 1 ) { setLocation(getX(), getY() + 3 ); } else if (getY() == 399 ) { setLocation(getX(), getY() - 3 ); } } } } |