Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Maze Help with case construct
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
14melody




PostPosted: 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
Sponsor
sponsor
14melody




PostPosted: 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




PostPosted: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
tyuo9980




PostPosted: 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




PostPosted: 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




PostPosted: 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




PostPosted: 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
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: