Greenfoot doesn't react..
In my game (a hero defense) i made a mouse movement. After compiling and running the project nothing happens. Where is the mistake?
It would be awesome if someone could help me. Greenfoot doesn't even say there's a mistake.
/regards
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Level here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Level extends World
{
/**
* Constructor for objects of class Level.
*
*/
int targetpointx;
int targetpointy;
int heropointx;
int heropointy;
int xway;
int yway;
double way;
double steps;
double stepsizex;
double stepsizey;
boolean heroint=true;
Hero hero = new Hero();
public Level()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(600, 600, 1);
hero();
}
public void hero()
{
addObject(hero, 300, 300);
hero.setRotation(47);
}
public void act()
{
movement();
}
public void movement(){
if (Greenfoot.mouseClicked(this)) {
MouseInfo mouse = Greenfoot.getMouseInfo();
heropointx=hero.getX();
heropointy=hero.getY();
targetpointx=mouse.getX();
targetpointy=mouse.getY();
xway = targetpointx - heropointx;
yway = targetpointy - heropointy;
way = Math.sqrt(xway*xway+yway*yway);
steps = way/2;
int step = (int)steps;
int stepx = (int)stepsizex;
int stepy = (int)stepsizey;
int i = 0;
for(i=0;i<=step;i++){
hero.setLocation(heropointx+stepx, heropointy+stepy);
}
}
}
}