@hkrhässleholm, it is not horrible programming to have code in the act method, it just makes it less readable when there is alot of code there, which would becomes poor programming.
* see http://docs.oracle.com/javase/tutorial/java/nutsandbolts/for.html on how to construct a 'for' loop; and 'i++' is the same as 'i=i+1'
*"board.snake[i].setLocation(board.snake[i-1].getX(),board.snake[i-1].getY());" move the snake (segment) to the position of the one in front of it, repeating this starting from the back of the snake will move the whole snake body forward one step
*the checks in the 'if statement make sure the snake is in world limits after a tentative move, checking each edge
*the 'Actor body =..." gets the snake object that is located two places forward from the head of the snake, if one exists there. What the code is doing is looking ahead 2 places to see if the head of the snake will run into its body; in context, by using this, the code is saying "if the head moves toward the body and will hit the body on the next move if allowed to continue in the same direction, then end the game right then." The game ends on a tentative collision, not on a collision (programmer preference?).
I hope that answers your questions.
@kiwii, re-download the source and replace the code for the SWorld class back into your scenario. I had inadvertently forget to add the overrides on 'removeObject'. They were finally added in my last update. Thanks.
@To All Who Have Downloaded This Prior To Last Update, please re-download source to correct problem with 'removeObject' situations.
I do believe this project is complete. If anyone encounters any problems of any kind, or has any concerns, please do not hesitate to leave a comment. Also, if you can think of any improvements or have any suggestions, I would like to know about them. On the brighter side, if you have any raves, or if you so feel moved to, again, please do not hesitate to post up.
In your Vector class, in the 'sin_theta2' and 'cos_theta2' methods, you are bringing in 'angle' as an 'int' parameter. They need cast to 'double' while converting to radians.
[code]double a = (double) angle/180.0*PI;[/code]
@chantry2012, click on 'Scenarios' near the top of the page (second from the right, near your icon, if you are logged in). On the bottom of the scenario page, under 'Browse by tag', click on the world 'Game'.
I think what fireandIce means is that the squares within a radius of the campfire can be illuminated determined by the direct distance from the campfire (instead of the sum of the x and y offsets determining the amount of illumination for each square).
@jabirfatah91, (1) 'private' is not neccessary, but will restrict access from other classes; 'double' is used for more precise movement. (2) with 'first' initially set to 'true', the code block that is executed on the condition 'if (first)' will execute. (3a) Since 'first' is changed within the block to 'false' (by 'first = !first;'), the block is destined to only run once (the first time the act method is executed). (3b) 'System.currentTimeMillis()' is a system command to return the 'long' value of the current system time. Each unit of time returned is equivalent to 1/1000th of a second.
2012/11/22
Lab 6 – Snake
2012/11/22
Scrolling SuperWorld
2012/11/21
Scrolling SuperWorld
2012/11/21
Scrolling SuperWorld
2012/11/18
TrainingDrawLine
2012/11/14
Fractal Slideshow
2012/11/12
Adventure
2012/11/11
Light System
2012/11/10
Lab 5 – Shot from a cannon