ok, i did as danpost had suggested before about creating a bar in the game so the player could still control the speed if they wanted to get faster or slower, but it isn't controlling it properly. if i click to the right of the halfway point, it speeds it up to an extent, and then stops or starts slowing back down. the same applies to the left point, it slows down to an extent, then starts speeding back up again. doesn't seem to make it go to the speed i want it where i click it.
here's my speed bar coding:
public class actBar extends Actor { /** * Act - do whatever the actBar wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ GreenfootImage bar = new GreenfootImage(200, 20); int X, xX; boolean barLess = false; boolean barMore = false; int spd = 0; public actBar() { bar.setColor(new Color(255, 255, 255)); bar.fill(); bar.drawRect(0, 0, 200, 20); bar.setColor(new Color(0, 0, 0)); bar.drawRect(5, 5, 190, 10); bar.fillRect(5, 5, 190, 10); setImage(bar); Greenfoot.setSpeed(50); } public void act() { // Add your action code here. if(Greenfoot.mouseClicked(this)) { MouseInfo mouse = Greenfoot.getMouseInfo(); X = mouse.getX(); if(X > 750 && X < (750 + (190/2)))//750 is the halfway point of the picture { X = X - 750; barMore = true; barLess = false; //increase speed //Greenfoot.setSpeed(50 + X); spd = X; adjustSpd(spd); } if(X < 750 && X > (750 - (190/2))) { X = 750 - X; barLess = true; barMore = false; //decrease speed //Greenfoot.setSpeed(50 - X); spd = X; adjustSpd(spd); } if(X == 750) { Greenfoot.setSpeed(50); } } barUpdate(X); } public void barUpdate(int x) { bar.clear(); bar.setColor(new Color(255, 255, 255)); bar.fill(); bar.setColor(new Color(0, 0, 0)); bar.drawRect(5, 5, 190, 10); bar.fillRect(5, 5, 190, 10); bar.setColor(new Color(255, 0, 0)); bar.drawRect(5, 5, 190, 10); if(barLess) { bar.fillRect(5, 5, 95 - X, 10); } if(barMore) { bar.fillRect(5, 5, 95 + X, 10); } if(!barLess && !barMore) { bar.fillRect(5, 5, 95, 10); } setImage(bar); } public void adjustSpd(int spd) { if(spd >= 1) { Greenfoot.setSpeed(50 + spd); } if(spd <= -1) { Greenfoot.setSpeed(50 - spd); } } }