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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | 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); } } } } |