Computer Science Canada Need help creating boundaries for a maze game |
Author: | MI [ Wed Mar 27, 2013 2:30 am ] |
Post subject: | Need help creating boundaries for a maze game |
I am trying to make a maze game using Turing. I REALLY need help making the maze walls. I want my character to move through the maze and not be able to walk right through the maze walls. How do I create boundaries? Any help is appreciated:) Describe what you have tried to solve this problem I tried looking at forums and Turing game examples but it's really difficult to understand. I am kinda new to this program. Please specify what version of Turing you are using Turing 4.1.1 |
Author: | Nathan4102 [ Wed Mar 27, 2013 7:47 am ] |
Post subject: | RE:Need help creating boundaries for a maze game |
Hmm, You could draw your lines using the turing graphics functions, and then create an imaginary boundary one pixel away from that line. Then every time you try to move, turing will check if we are standing on one of these imaginary boundaries. If we are, don't move? If you need explanation, I could probably code a small example. |
Author: | Raknarg [ Wed Mar 27, 2013 1:10 pm ] | ||
Post subject: | RE:Need help creating boundaries for a maze game | ||
Think about it. If you're past a bound, basically set the thing behind or on the bound. Now x and y won't escape the screen. |
Author: | MI [ Wed Mar 27, 2013 9:19 pm ] | ||
Post subject: | Re: RE:Need help creating boundaries for a maze game | ||
Raknarg @ Wed Mar 27, 2013 1:10 pm wrote:
I am not getting how exactly to add it to my code. Suppose I want (just for an example) a character to go through a maze and I don't want it to be able to pass a maze wall: var x, y : int x := 100 y := 100 var chars : array char of boolean loop Input.KeyDown (chars) if chars (KEY_UP_ARROW) then y := y + 5 elsif chars (KEY_RIGHT_ARROW) then x := x + 5 elsif chars (KEY_LEFT_ARROW) then x := x - 5 elsif chars (KEY_DOWN_ARROW) then y := y - 5 end if drawfilloval (x, y, 10,10, blue) delay (10) cls drawline (0,50,500,50,black) end loop In this above code, how can I make the circle not be able to go past the line? I know you already gave me the idea but I just don't know how to add it to this. Please help! Thank you so much Oh and if possible, do you know how to make the flashing stop? |
Author: | MI [ Wed Mar 27, 2013 9:23 pm ] | ||
Post subject: | Re: RE:Need help creating boundaries for a maze game | ||
Nathan4102 @ Wed Mar 27, 2013 7:47 am wrote: Hmm, You could draw your lines using the turing graphics functions, and then create an imaginary boundary one pixel away from that line. Then every time you try to move, turing will check if we are standing on one of these imaginary boundaries. If we are, don't move? If you need explanation, I could probably code a small example.
Here's my example of a code (a moving circle as a character and a line as a maze wall):
How would I add boundaries to the line so that the circle can't go past the line and instead, collide with it? |
Author: | Dragon20942 [ Fri Mar 29, 2013 4:01 pm ] |
Post subject: | RE:Need help creating boundaries for a maze game |
It will be an if statement. Pseudocode: if the character's position is beyond the boundary reverse the action that caused it to happen end if |
Author: | Cancer Sol [ Fri Mar 29, 2013 4:14 pm ] |
Post subject: | Re: Need help creating boundaries for a maze game |
Quote: If you're past a bound, basically set the thing behind or on the bound.
Omg, that's so smart I never thought of that before |
Author: | Zren [ Fri Mar 29, 2013 6:12 pm ] |
Post subject: | RE:Need help creating boundaries for a maze game |
Instead of moving the variable back (to most likely a constant location), don't move it at all in the first place. Use a temporary variable to calculate it's destination. Then, if that destination is valid, assign the value. |
Author: | Raknarg [ Sat Mar 30, 2013 8:41 pm ] |
Post subject: | RE:Need help creating boundaries for a maze game |
That's how they do vector collision, right? |
Author: | MI [ Tue Apr 02, 2013 4:12 pm ] |
Post subject: | RE:Need help creating boundaries for a maze game |
Thank you guys!!! I think I got it |
Author: | basi [ Thu Mar 28, 2019 10:39 am ] | ||
Post subject: | Re: RE:Need help creating boundaries for a maze game | ||
MI @ Wed Mar 27, 2013 9:19 pm wrote: Raknarg @ Wed Mar 27, 2013 1:10 pm wrote:
I am not getting how exactly to add it to my code. Suppose I want (just for an example) a character to go through a maze and I don't want it to be able to pass a maze wall: var x, y : int x := 100 y := 100 var chars : array char of boolean loop Input.KeyDown (chars) if chars (KEY_UP_ARROW) then y := y + 5 elsif chars (KEY_RIGHT_ARROW) then x := x + 5 elsif chars (KEY_LEFT_ARROW) then x := x - 5 elsif chars (KEY_DOWN_ARROW) then y := y - 5 end if drawfilloval (x, y, 10,10, blue) delay (10) cls drawline (0,50,500,50,black) end loop In this above code, how can I make the circle not be able to go past the line? I know you already gave me the idea but I just don't know how to add it to this. Please help! Thank you so much Oh and if possible, do you know how to make the flashing stop? you can stop the flasing by doing this View.Set ("graphics:350;400,offscreenonly") its what i did, it should work to stop the flickering |