Computer Science Canada

Maze Help with case construct

Author:  14melody [ 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?

Author:  14melody [ 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

Author:  Tony [ 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.

Author:  tyuo9980 [ 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

Author:  darkage43 [ 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

Author:  14melody [ 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?

Author:  goroyoshi [ 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
Turing:

if whatdotcolour (x+ radius of circle + 1, y) = color of maze then
    x -= 1
end if


: