I just have a quick question. Is it in some way possible to turn by degrees that are not whole numbers (i.e. 1,2,3...360). ?
Instead I would like to turn in smaller intervals (i.e. 0.1, 0.2, 0.3... 360).
public void act()
{
if (Greenfoot.isKeyDown("left"))
{
turnLeft();
}
if (Greenfoot.isKeyDown("right"))
{
turnRight();
}
}public void turnLeft()
{
turn(-turnSpeed);
}
public void turnRight()
{
turn(turnSpeed);
}public void drawSightV2()
{
GreenfootImage drawerImg = getWorld().getObjects(Drawer.class).get(0).getImage();
drawerImg.clear();
int distance = 0;
int xSave = getX();
int ySave = getY();
double tileMaxHeight = 800.0;
int tileWidth = 10;
int colourD = 4;
int h1;
int maxSight = ((1400/tileWidth)/2);
for(int n = 0; n <= maxSight; n++)
{
turn(n);
while(!isTouching(Wall.class))
{
distance = distance + 10;
move(10);
}
h1 = (int)(tileMaxHeight*((1400.0-distance)/(1400.0)));
if(h1/colourD > 255 || h1 == 0)
drawerImg.setColor(new Color(255, 255, 255));
else
drawerImg.setColor(new Color(h1/colourD, h1/colourD, h1/colourD));
drawerImg.fillRect(690+(n*tileWidth), 450 - (h1/2), tileWidth, h1);
setLocation(xSave, ySave);
distance = 0;
turn(-(2*n));
while(!isTouching(Wall.class))
{
distance = distance + 10;
move(10);
}
h1 = (int)(tileMaxHeight*((1400.0-distance)/(1400.0)));
if(h1/colourD > 255 || h1 == 0)
drawerImg.setColor(new Color(255, 255, 255));
else
drawerImg.setColor(new Color(h1/colourD, h1/colourD, h1/colourD));
drawerImg.fillRect(690-(n*tileWidth), 450 - (h1/2), tileWidth, h1);
setLocation(xSave, ySave);
distance = 0;
turn(n);
}
}