Author |
Message |
14melody
|
Posted: Sun May 29, 2011 7:34 pm Post subject: Maze Help with case construct |
|
|
I need help making a maze using arrow keys, boarder restrictions and case construct.
I'm really confused and don't get case construct.
can someone give me an example for the coding for the left arrow? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
14melody
|
Posted: Mon May 30, 2011 4:08 pm Post subject: RE:Maze Help with case construct |
|
|
okay, so I figured how to move my object around the maze. How do I restrict the user within the boarder now?
case ord (nextCh) of
label right:
x := x + 10
label left:
x := x - 10
label down:
y := y - 10
label up :
y := y + 10
end case |
|
|
|
|
|
Tony
|
Posted: Mon May 30, 2011 4:13 pm Post subject: RE:Maze Help with case construct |
|
|
You check if there's a wall in between "x" and "x + 10". The data-structure choice for how you want to represent walls is up to you. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
tyuo9980
|
Posted: Mon May 30, 2011 5:01 pm Post subject: Re: Maze Help with case construct |
|
|
you can use collision detection, and theres a couple of ways to do it. but for this case i would use whatdotcolour |
|
|
|
|
|
darkage43
|
Posted: Mon May 30, 2011 7:57 pm Post subject: RE:Maze Help with case construct |
|
|
whatdotcolour is probably easy to to do since your maze would be a single colour |
|
|
|
|
|
14melody
|
Posted: Tue May 31, 2011 4:48 pm Post subject: Re: Maze Help with case construct |
|
|
so i did this:
loop
colour := View.WhatDotColour (x - 15, y + 15)
colour2 := View.WhatDotColour (x + 15, y - 15)
if colour = 0 and colour2 = 0 then
getch (nextCh)
drawfilloval (x, y, 10, 10, white)
case ord (nextCh) of
label right :
x := x + 10
label left:
x := x - 10
label down:
y := y - 10
label up:
y := y + 10
end case
end if
how would I move the circle again once it detected the wall? |
|
|
|
|
|
goroyoshi
|
Posted: Tue May 31, 2011 6:36 pm Post subject: RE:Maze Help with case construct |
|
|
thats not what they had in mind,
also use syntax tags
[ syntax="turing"]
[ /syntax]
no spaces
this is an example of using a circle with this
|
|
|
|
|
|
|