Computer Science Canada Hit detection mishap |
Author: | neuro.akn [ Mon Jan 14, 2013 12:46 pm ] | ||
Post subject: | Hit detection mishap | ||
What is it you are trying to achieve? My helicopter game is experiencing some glitching. When the user hits an obstacle, it will sometimes clear to the game over screen. However, most times, it will just return to the game menu. I am trying to find a way of fixing this problem so if the user hits ANYTHING it will clear to the game over screen. What is the problem you are having? Most times, the game will just return to the menu if the helicopter has hit something. I want it to clear to the game over screen; it only does this sometimes. Not all the time. Describe what you have tried to solve this problem I'm not too sure where to start to try and fix this problem. Any help is appreciated. Thank you. Post any relevant code (You may choose to attach the file instead of posting the code if it is too long) <Answer Here>
Please specify what version of Turing you are using <Answer Here> |
Author: | Insectoid [ Mon Jan 14, 2013 1:07 pm ] |
Post subject: | RE:Hit detection mishap |
It's kinda hard to find out what's wrong if we can't see your code. |
Author: | neuro.akn [ Mon Jan 14, 2013 1:28 pm ] |
Post subject: | RE:Hit detection mishap |
if btn = 1 then yaltitude += 1 %Button clicked - ascends the helo else yaltitude -= 1 %Button not clicked - descends helo end if Basically to ascend and descend the helicopter. And I have it clearing the screen for the game over screen but it sometimes does not work. |
Author: | GuCCIP [ Mon Jan 14, 2013 1:29 pm ] |
Post subject: | Re: Hit detection mishap |
You can use if whatdotcolor = (color of obstacle) then (whatever you want to happen if they hit it) end if |
Author: | Insectoid [ Mon Jan 14, 2013 2:13 pm ] |
Post subject: | RE:Hit detection mishap |
You still haven't provided enough code for us to work with. How am I supposed to help you if I can't see what you've done? |
Author: | neuro.akn [ Tue Jan 15, 2013 11:34 am ] |
Post subject: | RE:Hit detection mishap |
if whatdotcolor (125, 192 + yaltitude) = white then exit end if if whatdotcolor (12, 192 + yaltitude) = white then exit end if if whatdotcolor (150, 253 + yaltitude) = white then exit end if I have this, but it still only clears to the game over screen some of the time.. |
Author: | Panphobia [ Tue Jan 15, 2013 11:37 am ] |
Post subject: | RE:Hit detection mishap |
is that all your code? |
Author: | neuro.akn [ Tue Jan 15, 2013 11:40 am ] |
Post subject: | RE:Hit detection mishap |
My program is over 800 lines. I just provided the code for the ascending and descending helicopter, and what is supposed to be and exit to the game over screen if the user hits the obstacles. In addition, the only time it will clear to the game over screen is when the helicopter descends into the bottom "edge" I have placed at the bottom of the execution window. |
Author: | Insectoid [ Tue Jan 15, 2013 12:12 pm ] |
Post subject: | RE:Hit detection mishap |
Quote: if the user hits the obstacles
Maybe this is the part you should be showing us. |
Author: | neuro.akn [ Tue Jan 15, 2013 12:16 pm ] |
Post subject: | RE:Hit detection mishap |
I just showed that... |
Author: | Panphobia [ Tue Jan 15, 2013 2:44 pm ] |
Post subject: | RE:Hit detection mishap |
what insectoid means is post enough code so we can see exactly what the problem is, you giving that excerpt of code does not show us what it is controlling etc, so try to upload your whole turing file on a post, or post all the code pertaining to your problem |
Author: | Tony [ Tue Jan 15, 2013 3:20 pm ] | ||
Post subject: | RE:Hit detection mishap | ||
it's a balance between "show all of the code", which is unlikely to be read, and enough code to demonstrate the problem. Ideally it will be a complete self-contained example that clearly demonstrates the problem. Such a skill is likely beyond the high school level. @OP -- your first steps for solving the problem is identifying reproducible steps. That is, conditions when the problem occurs all of the time, not "sometimes it breaks". It sounds like you are moving in the right direction Quote: when the helicopter descends into the bottom "edge" and some of the code
suggests that you have multiple points of exit (those lines seem to deal with the upper edge; presumably you have even more exit statements for the bottom edge). Code repetition is bad just for this reason -- you have multiple blocks that are doing essentially the same thing, and one of them is slightly different than the others, causing problems. |
Author: | neuro.akn [ Wed Jan 16, 2013 11:37 am ] |
Post subject: | RE:Hit detection mishap |
Okay, I understand. Thanks! I think I know what I can do to change this problem; I'm going to create a procedure and call it after the hit. That way it will clear to the procedure instead of just the main menu. That seems like the only way I could fix it in the limited time I have to finish. Thank you. |