
-----------------------------------
14melody
Sun May 29, 2011 7:34 pm

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?

-----------------------------------
14melody
Mon May 30, 2011 4:08 pm

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
Mon May 30, 2011 4:13 pm

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.

-----------------------------------
tyuo9980
Mon May 30, 2011 5:01 pm

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
Mon May 30, 2011 7:57 pm

RE:Maze Help with case construct
-----------------------------------
whatdotcolour is probably easy to to do since your maze would be a single colour

-----------------------------------
14melody
Tue May 31, 2011 4:48 pm

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
Tue May 31, 2011 6:36 pm

RE:Maze Help with case construct
-----------------------------------
thats not what they had in mind, 
also use syntax tags

if whatdotcolour (x+ radius of circle + 1, y) = color of maze then
    x -= 1
end if

