Computer Science Canada messed up counter |
Author: | x-ecutioner [ Wed Nov 26, 2008 8:45 pm ] | ||
Post subject: | messed up counter | ||
hi im making basic collision detection, you have a paddle (controlled by the users paddle) which shoots another circle at a moving square. The collision aspect behind the script works fine, the issue is the counter goes up by different numbers each time. here is my code. any ideas? youll find the actual hits recording located inside the squaretohit process
thanks very much. |
Author: | DanielG [ Wed Nov 26, 2008 10:10 pm ] |
Post subject: | RE:messed up counter |
I haven't had much of a chance to look at your actual code, but forks are bad and evil, and may be the cause of the problem. If they aren't, then you still shouldn't be using them. You can find the explanation somewhere in the turing help section (I think). |
Author: | darkangel [ Thu Nov 27, 2008 10:42 pm ] | ||
Post subject: | Re: messed up counter | ||
DanielG is right. You shouldn't be using processes in Turing. Turing has this tendency to execute them at random times, unlike ANY other language. However processes arn't EVIL like DanielG said, just you should try to stay away from them wherever possible. Especially when your program is as simple as it is, what I suggest is replace all the processes with procedures then replace the "forks" with...
This is the link http://compsci.ca/v3/viewtopic.php?t=7842&highlight=process by the way EDIT: Also the reason why your getting different numbers is because you do collision detection every frame even AFTER the small ball already hit it. So lets say that in frame 3 it hits the big circle, you then get a point, then in frame 4 you add to the 'y' value and check for collision again. And guess what, the small ball is STILL inside the big one, guess we add another point. etc... After it hits once, you have to get rid of the small ball. |