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

2018/2/5

Mouse dragging and collision

1
2
danpost danpost

2018/2/7

#
Change line 61 back. The move should always be value as any adjacent valid location to the empty location will have a mover. With the way the offsets were arrived at, no invalid locations will be among them. Also, collision checking fails during the 'for' loop. That is why I rearranged the parts of the code -- to avoid collision checking when not needed.
danpost danpost

2018/2/7

#
Where is the 'act' method in your wold class that is to detect game over?
maenstru56 maenstru56

2018/2/7

#
"Act" mthod in world? I didn't know this was a thing, I thought that "if" from the constructor will do the work if I add Greenfoot.stop() alongside with the end photo. How does that work?
danpost danpost

2018/2/7

#
maenstru56 wrote...
"Act" mthod in world? I didn't know this was a thing,
Yes -- act method in the world. The act method is for what an actor needs to repeatedly do; the act method of the world is for what needs to be done repeatedly by the world. General game play codes usually go within the world. The continuous checking for game over is not a behavior of any actor; it is something that the world should perform. Just add an 'act' method (just like it appears in an Actor subclass) to the world class code and check for game over in it. The constructor is only executed once, when the object is being created. You cannot put any code that needs to continuously execute in it.
maenstru56 maenstru56

2018/2/7

#
It works perfectly! Thank you for all the help and the patience, I learned how to do a lot of stuff from you, keep it up :)
You need to login to post a reply.
1
2