For my tank game i am trying to let a bullet fly from a tank
the bullets gets added to the world using this:
and the code i have in the shell itself is:
anyone can help me why it doesnt want to go in the correct angle and only wants to go 45* 90* etc etc
public boolean atWorldEdge()
{
if(getX() < 10 || getX() > getWorld().getWidth() - 10)
return true;
if(getY() < 10 || getY() > getWorld().getHeight() - 10)
return true;
else
return false;
} import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class TankShell here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class TankShell extends Ammo
{
/**
* Act - do whatever the TankShell wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
private int speed1 = 5;
public void act()
{
// Add your action code here.
//move(5);
Smove();
checkSide();
}
public void Smove()
{
int x1 = getX();
int y1 = getY();
int ww1 = getWorld().getWidth();
int wh1 = getWorld().getHeight();
x1 += Math.cos(Math.toRadians(getRotation()))*speed1;
y1 += Math.sin(Math.toRadians(getRotation())) * speed1;
x1 = 1+(x1+(ww1-3))%(ww1-2);
y1 = 1+(y1+(wh1-3))%(wh1-2);
setLocation((int)x1, (int)y1);
}
}


