because greenfoot uses an int move, there is the problem where when moving at the speed of 1 you can only move in 8 directions, so im trying to solve this with a double move where i store the double and update the x and y displacements. but it's not working quite right :/ and i don't know what i did wrong.
the code
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.lang.Math; /** * move in double * * @author RUMMAKER * @version 1.0 */ public class SmoothMover extends Actor { public double vecterX; public double vecterY; public double currentX; public double currentY; public int moveX; public int moveY; public int angle; public void move(double speed) { angle = getRotation(); vecterX = Math.cos((double)angle)*speed; vecterY = Math.sin((double)angle)*speed; currentX += vecterX; currentY += vecterY; moveX = (int)currentX; moveY = (int)currentY; setLocation(getX() + moveX, getY() + moveY); currentX -= (double)moveX; currentY -= (double)moveY; } }