Maze Problem
Author |
Message |
GuCCIP
|
Posted: Sat Jan 05, 2013 2:43 pm Post subject: Maze Problem |
|
|
What is it you are trying to achieve?
How do you direct the whatdotcolor if statement to the mainMenu procedure when the circle or "mouse" has touched the purple line?
(Click on Easy when choosing new game)
What is the problem you are having?
If I directly say the procedure it starts flashing (mainly because it's in a loop) so then i take it out or i use the if statement in another
procedure and then call the procedure in the original if statement it simply doesn't work
FYI, look at this part:
if whatdotcolor (x, y) = purple then
mainMenu
tries := tries + 1
else
if whatdotcolor (x, y) = yellow then
display
end if
Turing: |
import GUI
var mainWin := Window.Open ("position:5;100,graphics:1000,500")
var x, y : int
var move : array char of boolean
var cheese : boolean := false
var MenuButton : int := 0
var Ttime : int := 0
var points : int := 0
var tries : int := 0
x := 315
y := 115
points := points - tries * Ttime
forward proc mainMenu
proc title
cls
locate (1, 60)
put "The Maze"
put ""
end title
proc display
end display
proc userInput2
var menubutton4 : int
loop
title
drawline (300, 100, 700, 100, purple) %Bottom Border
drawline (700, 100, 700, 400, purple) %Right Border
drawline (300, 100, 300, 400, purple) %Left Border
drawline (300, 400, 700, 400, purple) %Top Border
drawline (300, 140, 430, 140, purple) %Line1
drawline (500, 100, 500, 200, purple) %Line2
drawline (350, 200, 560, 200, purple) %Line3
drawline (350, 200, 350, 350, purple) %Line4
drawline (560, 200, 560, 280, purple) %Line5
drawline (410, 350, 410, 280, purple) %Line6
drawline (410, 280, 500, 280, purple) %Line7
drawline (460, 400, 460, 350, purple) %Line8
drawline (500, 280, 500, 350, purple) %Line9
drawline (500, 350, 700, 350, purple) %Line10
drawline (700, 140, 570, 140, purple) %Line11
drawline (610, 280, 610, 140, purple) %Line12
drawline (650, 350, 650, 200, purple) %Line13
drawfilloval (670, 120, 5, 5, yellow) %Cheese
locate (3, 10)
put "Tries: ", tries
if whatdotcolor (x, y ) = purple then
mainMenu
tries := tries + 1
else
if whatdotcolor (x, y ) = yellow then
display
end if
Input.KeyDown (move )
if move (KEY_UP_ARROW) then
y := y + 1
elsif move (KEY_RIGHT_ARROW) then
x := x + 1
elsif move (KEY_LEFT_ARROW) then
x := x - 1
else
if move (KEY_DOWN_ARROW) then
y := y - 1
end if
end if
drawfilloval (x, y, 4, 4, gray)
drawfilloval (x, y, 2, 2, black)
delay (10)
end if
end loop
end userInput2
proc userInput3
end userInput3
proc userInput4
end userInput4
proc userInput1
var menubutton2, Easy, Medium, Hard : int
title
menubutton2 := GUI.CreateButton (850, 25, 0, "Menu", mainMenu )
Easy := GUI.CreateButton (225, 275, 0, "Easy", userInput2 )
Medium := GUI.CreateButton (475, 275, 0, "Medium", userInput3 )
Hard := GUI.CreateButton (725, 275, 0, "Hard", userInput4 )
end userInput1
proc Instructions2
cls
var menubutton3 : int
title
locate (5, 1)
put "Your a mouse! Your job is to go get the cheese! Try and get through the maze but don't touch the walls as you'll get poisoned and die!"
locate (10, 1)
put "Use the arrow keys to move around, and remember, the longer it takes you to complete the maze the less points you'll end up"
locate (11, 2)
put "with! Have fun!"
menubutton3 := GUI.CreateButton (850, 25, 0, "Menu", mainMenu )
end Instructions2
body proc mainMenu
var Start, Instructions, Continue, Exit := 0
title
Start := GUI.CreateButton (478, 400, 0, "Start", userInput1 )
Instructions := GUI.CreateButton (478, 350, 0, "Intructions", Instructions2 )
Continue := GUI.CreateButton (478, 300, 0, "Continue", userInput1 )
Exit := GUI.CreateButtonFull (478, 250, 0, "Exit", GUI.Quit, 0, KEY_ESC, false)
end mainMenu
proc goodBye
title
locate (10, 45)
put "This program was made by"
locate (20, 60)
put "GoodBye!"
delay (2000)
Window.Close (mainWin )
end goodBye
proc intro
var menubutton : int
title
menubutton := GUI.CreateButton (850, 25, 0, "Menu", mainMenu )
end intro
intro
loop
exit when GUI.ProcessEvent
end loop
goodBye
|
Please specify what version of Turing you are using
4.1.1 |
|
|
|
|
|
Sponsor Sponsor
|
|
|
evildaddy911
|
Posted: Sat Jan 05, 2013 3:15 pm Post subject: RE:Maze Problem |
|
|
body proc mainMenu
var Start, Instructions, Continue, Exit := 0
see anything wrong about this? |
|
|
|
|
|
GuCCIP
|
Posted: Sat Jan 05, 2013 3:22 pm Post subject: Re: Maze Problem |
|
|
Fixed but still doesn't fix my problem. |
|
|
|
|
|
evildaddy911
|
Posted: Sat Jan 05, 2013 3:43 pm Post subject: RE:Maze Problem |
|
|
I don't know much about the GUI module, so try checking the Turing Walkthrough for some more information |
|
|
|
|
|
GuCCIP
|
Posted: Sat Jan 05, 2013 3:56 pm Post subject: Re: Maze Problem |
|
|
My problem isn't about GUI's, it's how to make it change from one procedure to another without error.
Saying again that error that im talking about is in the whatdotcolor if statement. |
|
|
|
|
|
Insectoid
|
Posted: Sat Jan 05, 2013 3:59 pm Post subject: RE:Maze Problem |
|
|
You don't want to switch from one procedure to another. Your game is already running 'inside' a main menu procedure. If your game procedure exits, it should automatically return to the main menu procedure. You need to design your menu proc so that when the game exits, the menu keeps doing what it was doing before the game started. |
|
|
|
|
|
Michael3176
|
Posted: Sat Jan 05, 2013 4:08 pm Post subject: RE:Maze Problem |
|
|
add this to your global variables
var loser : boolean
then and in
userInput
if whatdotcolor (x, y) = purple then
loser := true
tries := tries + 1
and at the bottom add
exit when loser = true
end loop
mainMenu |
|
|
|
|
|
GuCCIP
|
Posted: Sat Jan 05, 2013 4:32 pm Post subject: Re: Maze Problem |
|
|
I'm left with a different problem but thanks anyways. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
|
|