This site requires JavaScript, please enable it in your browser!
Greenfoot back

Super_Hippo's Comments

Back to Super_Hippo's profile

I think it is a two player game. Player A creates a new pattern and memorizes it. Player B clicks on one square while Player A is not watching. The square's color inverts. Player A then tries to find out which square was changed and clicks it.
I am not exactly sure what causes it, but you are making it harder than it is. If your Body/Head extend Snake, you should not have fields with the same name as in the Snake class. How I just made it work: Remove all "direction" variables, the "go" and "calcV" methods, simply turn the actor in the direction it should move and move it with the move method. Then when adding a new body part, you can add it to the world with the same rotation as the last one and move it back one cell. Save the "prevdir" at the beginning of the act method of Body/Head.
"Press start" --> Have to press space to start
Oh, it is also not really needed that the calculation is done every act-cycle. You only need to execute it once (or once every time something changed).
I just saw this image here https://i.gyazo.com/a5aeacfa6056d5a15af753f781274b06.png and noticed that something had to be wrong with the calculation of the shortest distance.
You distance method should be "return Math.hypot(x1-x2, y1-y2);". To test that your method doesn't work, execute this line: System.out.println(2^2); It prints 0 and that's not what you want to do. ^ is the XOR in Java, not the for powering a number. To calculate 2^2, you would need to use Math.pow(2, 2). The hypot method is a shortcut for Euclidian distances (= square-root of the sum of squared distances in each direction).
What error? Do you use Greenfoot version 3.1.0?
Thank you :)
I made my Pac-Man game with the help of this article: http://www.gamasutra.com/view/feature/3938/the_pacman_dossier.php?print=1 Was really helpful for me.