Computer Science Canada Maze Game: Collision and Levels. |
Author: | lasttimelord12 [ Sat Apr 25, 2015 12:31 pm ] | ||
Post subject: | Maze Game: Collision and Levels. | ||
What is it you are trying to achieve? I'm trying to make the walls collide with my character (a very detailed blue dot ![]() What is the problem you are having? My level process doesn't work unless I put the code in the movement loop. The collisions do not work either. Describe what you have tried to solve this problem I've tried using whatdotcolour, but I cannot figure out how to tell whatdotcolour what the wall colour is. Post any relevant code (You may choose to attach the file instead of posting the code if it is too long) <>
Please specify what version of Turing you are using 4.1.1 |
Author: | Dreadnought [ Sat Apr 25, 2015 12:53 pm ] |
Post subject: | Re: Maze Game: Collision and Levels. |
lasttimelord12 wrote: My level process doesn't work unless I put the code in the movement loop. I don't recommend using processes for anything other than playing audio files in the background unless you really know what you are doing. lasttimelord12 wrote: I've tried using whatdotcolour, but I cannot figure out how to tell whatdotcolour what the wall colour is. Actually that isn't really the problem here. Notice that you move your "character" 5 pixels per iteration of your loop so its coordinates will always be multiples of 5. Also, your upper boundary is drawn at the 350 pixel mark. Now suppose you are about the collide with the wall, what are your current coordinates? Does checking 1 pixel about your current position tell you if the wall is there? |
Author: | lasttimelord12 [ Sat Apr 25, 2015 12:58 pm ] |
Post subject: | Re: Maze Game: Collision and Levels. |
Dreadnought @ April 25th, 12:53 pm wrote: lasttimelord12 wrote: My level process doesn't work unless I put the code in the movement loop. I don't recommend using processes for anything other than playing audio files in the background unless you really know what you are doing. lasttimelord12 wrote: I've tried using whatdotcolour, but I cannot figure out how to tell whatdotcolour what the wall colour is. Actually that isn't really the problem here. Notice that you move your "character" 5 pixels per iteration of your loop so its coordinates will always be multiples of 5. Also, your upper boundary is drawn at the 350 pixel mark. Now suppose you are about the collide with the wall, what are your current coordinates? Does checking 1 pixel about your current position tell you if the wall is there? Aahh... You would think for somebody like me, who learnt basic game programming over the span of a year would notice these things... Also, I meant procedures...I type process. I'll fix that |
Author: | lasttimelord12 [ Sat Apr 25, 2015 2:52 pm ] |
Post subject: | Re: Maze Game: Collision and Levels. |
Dreadnought @ April 25th, 12:53 pm wrote: lasttimelord12 wrote: My level process doesn't work unless I put the code in the movement loop. I don't recommend using processes for anything other than playing audio files in the background unless you really know what you are doing. lasttimelord12 wrote: I've tried using whatdotcolour, but I cannot figure out how to tell whatdotcolour what the wall colour is. Actually that isn't really the problem here. Notice that you move your "character" 5 pixels per iteration of your loop so its coordinates will always be multiples of 5. Also, your upper boundary is drawn at the 350 pixel mark. Now suppose you are about the collide with the wall, what are your current coordinates? Does checking 1 pixel about your current position tell you if the wall is there? I changed the values, and all sides work except to the right. When moving right the dot still goes through the lines. Why is this? Here is the code Input.KeyDown (chars) if chars (KEY_UP_ARROW) and View.WhatDotColour(x,y+5) not= c then y := y + 5 end if if chars (KEY_RIGHT_ARROW)and View.WhatDotColour(x+5,y) not= c then x := x + 5 end if if chars (KEY_LEFT_ARROW) and View.WhatDotColour(x-5,y) not= c then x := x - 5 end if if chars (KEY_DOWN_ARROW) and View.WhatDotColour(x,y-5) not= c then y := y - 5 end if delay (10) cls drawfilloval (x, y, r, r2, blue) end loop |
Author: | Insectoid [ Sat Apr 25, 2015 3:08 pm ] |
Post subject: | RE:Maze Game: Collision and Levels. |
Your ball only moves by multiples of 5 and you only 5 pixels ahead, which means every time your ball moves there are 4 pixels that go unchecked. Where is your right wall? |
Author: | lasttimelord12 [ Sat Apr 25, 2015 4:04 pm ] |
Post subject: | Re: RE:Maze Game: Collision and Levels. |
Insectoid @ April 25th, 3:08 pm wrote: Your ball only moves by multiples of 5 and you only 5 pixels ahead, which means every time your ball moves there are 4 pixels that go unchecked. Where is your right wall?
My right wall is at drawline (639,0,639,400,black) starting at 639 x and 0y, ending at 639 x and 400y |
Author: | Insectoid [ Sat Apr 25, 2015 4:30 pm ] |
Post subject: | RE:Maze Game: Collision and Levels. |
Will 639 ever be checked by your collision detection algorithm? |
Author: | lasttimelord12 [ Sat Apr 25, 2015 4:39 pm ] |
Post subject: | Re: RE:Maze Game: Collision and Levels. |
Insectoid @ April 25th, 4:30 pm wrote: Will 639 ever be checked by your collision detection algorithm?
Oh, no it wouldn't because 639 isn't a multiple of 5.. Thanks! EDIT: Now the issue is that the ball gets stuck in between the walls. |
Author: | Insectoid [ Sat Apr 25, 2015 4:52 pm ] |
Post subject: | RE:Maze Game: Collision and Levels. |
There's a number of reasons that could happen. Try walking through your code starting when your ball is 1 frame away from hitting the wall. Go through the code yourself, writing down the value of each variable on paper every time it changes and evaluating all of the if/then statements yourself, without a computer. You will probably only have to do a couple of frames before you figure out what's going wrong. Remember, learning to debug properly is as important as learning to program at all. |