Computer Science Canada Game help (moving circle) |
Author: | Azzy123 [ Sat May 09, 2009 1:15 pm ] | ||||
Post subject: | Game help (moving circle) | ||||
What is it you are trying to achieve? I need to make it so that when my bigger yellow circle passes over the smaller circles, the smaller circles completely disappear- currently only parts of them are erased. What is the problem you are having? I have the distance formula, but no matter where I put it in my code, it's never called on/ never works. Describe what you have tried to solve this problem I've tried changing the formula a bit. I've also placed it nearly everywhere in my code. Post any relevant code (You may choose to attach the file instead of posting the code if it is too long) I've tried using this as my formula:
and then I put it under the " %redcookie" part of my code. I just need to make one circle (cookie) get eaten.
Please specify what version of Turing you are using 4.1 Edit: Sorry if it's a bit messy / impractical. It's my first attempt and I don't want to change it. |
Author: | Azzy123 [ Sat May 09, 2009 3:24 pm ] |
Post subject: | RE:Game help (moving circle) |
Bump.. This is urgent, thanks. |
Author: | Kharybdis [ Sat May 09, 2009 5:22 pm ] |
Post subject: | RE:Game help (moving circle) |
Your problem is that when your big circle moves over a small one, the trail of the big circle (you're moving it by increasing/decreasing its x and y position) is overlapping the smaller circle. To fix it, one way to do it (albeit not an impressive way) is when the x and y of the big circle are in the range defined by the small cookie (of x and y), then assign that small cookie to be black instead of its original colour. You can use the whatdotcolor function to do this, although i don't think it would be that efficient. |
Author: | Azzy123 [ Sat May 09, 2009 6:13 pm ] | ||
Post subject: | RE:Game help (moving circle) | ||
Er yeah. As I stated in my original post, that's what I've been trying to do. But it won't work. No idea why. I've been trying to use
|
Author: | OneTwo [ Sat May 09, 2009 6:58 pm ] | ||||||
Post subject: | Re: Game help (moving circle) | ||||||
Hey there, I've found a solution for you. Your current formula does not work, I haven't really thought of why it doesnt work but I made a solution for you. Solution: Here is a simple formula that will solve your problem, change a, b accordingly:
Explanation:
This is a simple formula, it gets the sum of the center coordinates of your yellow oval and the centre co-ordinates of your red dot. It then substracts it from each other. It then checks whether the difference is less than 10 or - 10 (10 is the radius of your yellow oval).
When your condition has been met, it will draw another oval over your red dot making it disappear. A and B is set to 0 so that you don't see a grey circle over your yellow oval. Comment out a := 0 and b := 0 and you'll see what I mean. Well that is all, hopefully I've helped you. : D |
Author: | TheGuardian001 [ Sat May 09, 2009 7:02 pm ] | ||
Post subject: | Re: Game help (moving circle) | ||
but you're only drawing it black if it disappears on its own (after the timer). what you need to do is check if the big yellow circle has hit the cookie, then set isredcookie (or whatever colour cookie) to false. in pseudo code
and so on. if you don't know how to do collision detection, I suggest you look here for square collisions (less effective in this case, but easier), or here for circular collision detection (a bit more complicated, but more accurate) Edit: aw.... ninja'd by OneTwo |
Author: | OneTwo [ Sat May 09, 2009 7:19 pm ] | ||||
Post subject: | Re: Game help (moving circle) | ||||
Sorry very small mistake,
That should read as
Mistake: ((x+y) - (a-b) > - 10 Corrected: ((x+y) - (a+b) > - 10 |
Author: | Azzy123 [ Sat May 09, 2009 7:49 pm ] |
Post subject: | RE:Game help (moving circle) |
Hi, sorry, either method still does not work. Where in the code would I need to put it? Thanks a lot for the help so far. ![]() |
Author: | OneTwo [ Sat May 09, 2009 8:39 pm ] | ||||
Post subject: | Re: Game help (moving circle) | ||||
Hey, the code works fine as I have just tested it. As for the location of the code, you can put it anywhere so long as it is executed every single time your object (yellow oval) moves. Example: it can be right after "loop ..." or even right before "end loop"
OR
Also note that you must change the variables(a, b) for it to work for the other cookies if you haven't already done so. |
Author: | Azzy123 [ Sat May 09, 2009 8:57 pm ] |
Post subject: | RE:Game help (moving circle) |
Hmmmmmmm. I have no idea why mine isn't working. I've done everything you've said, and I understand your formula.. but it the cookie still isn't being eaten. :s My brain feels like liquid. Thanks for your patience.. |
Author: | OneTwo [ Sat May 09, 2009 9:25 pm ] | ||||||
Post subject: | Re: Game help (moving circle) | ||||||
Hey, I added my code in to yours and here's the result: I just changed the BG to gray, no worries you could change it to whatever you want. Result:
Also note the minor changes to the conditional: From:
To:
|
Author: | Azzy123 [ Sat May 09, 2009 9:36 pm ] |
Post subject: | RE:Game help (moving circle) |
Hey, thanks a lot, but why is the timing so different? The cookies appear too quickly / slowly. Also, sometimes the red cookie appears at the bottom left of the screen (half appears on the screen and the other bit is cut off). The cookies seem to disappear randomly. Edit: Yeah, they seem to disappear when I approach from their left sides. |
Author: | OneTwo [ Sat May 09, 2009 10:05 pm ] |
Post subject: | RE:Game help (moving circle) |
It seems it has something to do with the way your counter works,so try experimenting with different ways to draw your random ovals. It's getting fairly late, i'll help you more tomorrow if that's fine with you. |
Author: | Azzy123 [ Sat May 09, 2009 10:07 pm ] |
Post subject: | RE:Game help (moving circle) |
Yes, I'll keep working on it. Thank you so much. |
Author: | OneTwo [ Sun May 10, 2009 12:13 pm ] | ||
Post subject: | Re: Game help (moving circle) | ||
Hey, it looks like my math was way off yesterday. Your formula is correct here is the more accurate code that should be used:
I'm very sorry if I made you confused in any way. |
Author: | Azzy123 [ Sun May 10, 2009 4:26 pm ] |
Post subject: | RE:Game help (moving circle) |
Ah, thank god. Works perfectly. I was wondering why my original formula wasn't working. Now it's glitch-free. Thanks! Now I guess I'll change it a bit to my liking. |
Author: | Azzy123 [ Sun May 10, 2009 4:38 pm ] | ||
Post subject: | Re: Game help (moving circle) | ||
In case you're interested, here's my near-final result:
Red = increases radius Green = decreases radius orange = increases speed cyan = decreases speed magenta = inverts keys -- doing it right now (and it's working ![]() The only problem that exists now is that there seems to be some yellow residue that's left behind after the inflated yellow bubble passes over a green cookie. |
Author: | Turing_Noob [ Sun May 10, 2009 5:05 pm ] |
Post subject: | RE:Game help (moving circle) |
post what you did for the magenta afterwards, i'm interested to see what you did for that since i wouldn't even know where to start if i had that assignment in other words i would be interested to see your finished assignment |
Author: | Azzy123 [ Sun May 10, 2009 5:26 pm ] |
Post subject: | Re: RE:Game help (moving circle) |
Turing_Noob @ Sun May 10, 2009 5:05 pm wrote: post what you did for the magenta afterwards, i'm interested to see what you did for that since i wouldn't even know where to start if i had that assignment in other words i would be interested to see your finished assignment
I was originally doing it one way, but the easiest way to do it is to append "-" before "step". This makes everything the opposite. ..If that makes sense to you. |
Author: | Turing_Noob [ Sun May 10, 2009 5:29 pm ] |
Post subject: | RE:Game help (moving circle) |
i have no idea what your talking about, can you please post the code. I usually understand it better if it's in code |
Author: | Azzy123 [ Sun May 10, 2009 5:32 pm ] |
Post subject: | RE:Game help (moving circle) |
Under the magenta bit, step:= -step. |
Author: | Turing_Noob [ Sun May 10, 2009 5:33 pm ] |
Post subject: | RE:Game help (moving circle) |
can you post your finished code, it'll be easier for me to understand that way |
Author: | Azzy123 [ Sun May 10, 2009 5:36 pm ] |
Post subject: | RE:Game help (moving circle) |
Er. Being my paranoid self, why are you so interested? |
Author: | Turing_Noob [ Sun May 10, 2009 5:39 pm ] |
Post subject: | RE:Game help (moving circle) |
i'm just curious that's all you see i'm making a game to and it would be get if i could add a feature similar to that |
Author: | Azzy123 [ Sun May 10, 2009 5:41 pm ] |
Post subject: | RE:Game help (moving circle) |
I'm very sorry, but if you need this code for your own project, just say so. You can't just walk in and copy + paste it to your own. It's very straightforward. Under the magenta cookie part, make step:= -step. I'm highly suspicious. ![]() |
Author: | Turing_Noob [ Sun May 10, 2009 5:44 pm ] |
Post subject: | RE:Game help (moving circle) |
thanks for the help |
Author: | OneTwo [ Sun May 10, 2009 5:58 pm ] |
Post subject: | RE:Game help (moving circle) |
Hey great job on the near-final product! I'm really liking it. For the yellow residue, you can do this: Draw a black oval over the green cookie first, then draw a black oval over your yellow cookie. Reduce the radius of your yellow cookie, then redraw your yellow cookie. |
Author: | Azzy123 [ Sun May 10, 2009 7:08 pm ] |
Post subject: | RE:Game help (moving circle) |
Works ![]() |