'Information frame on left
GraphicsWindow.BrushColor = "Gainsboro"
GraphicsWindow.FillRectangle(0,0,200,600)
'text in Info Frame
GraphicsWindow.BrushColor = "Black"
GraphicsWindow.DrawText(48,1,"Adventurer's Name")
GraphicsWindow.DrawText(48,80,"Map Coordinates:")
GraphicsWindow.DrawText(5,220,"Forward = Up Arrow")
GraphicsWindow.DrawText(5,240,"Back = Down Arrow")
GraphicsWindow.DrawText(5,260,"Turn left = Left Arrow")
GraphicsWindow.DrawText(5,280,"Turn right = Right Arrow")
GraphicsWindow.DrawText(5,320,"To start over = Back Space")
GraphicsWindow.DrawText(5,340,"End program = Esc")
'draw box around Maze-View window on the right
GraphicsWindow.PenColor = "White"
GraphicsWindow.PenWidth = 1
GraphicsWindow.DrawRectangle(200,0,600,600)
'Map data
' In advanced version there will be a MapWidth and MapHeight variable
' to know how much to read from map data file.
' (Map data file will be created by a Map Maker program. That program
' will allow users to create their own maps - future versions will allow for
' placement of RPG type components like monsters and treasure.)
'Start main program
While (Main)
DrawWalls()
DisplayCurrentXY() 'show coordinates in information frame.
loop = "True"
keyisupdated = "False"
WaitForKeyDownAndProcess()
EndWhile
Program.End()
Sub WaitForKeyDownAndProcess
While (loop)
If (keyisupdated = "True") Then
If (key = "Up") Then
'test if wall is blocking forward movement
If NoForward = "True" Then
HitWall()
keyisupdated = "False"
Else
loop = "False"
'find facing and update current position based on forward movement.
If Facing = 1 Then
CurrentY = CurrentY - 2
ElseIf Facing = 2 Then
CurrentX = CurrentX + 2
ElseIf Facing = 3 Then
CurrentY = CurrentY + 2
ElseIf Facing = 4 Then
CurrentX = CurrentX - 2
EndIf
EndIf
EndIf
If key = "Left" Then
NoForward = "False"
loop = "False"
Facing = Facing - 1
If Facing < 1 Then
Facing = 4
Endif
EndIf
If key = "Right" Then
NoForward = "False"
loop = "False"
Facing = Facing + 1
If Facing > 4 Then
Facing = 1
EndIf
EndIf
If key = "Down" Then
loop = "False"
'Make sure no wall behind you and then move back one.
If Facing = 1 and Text.GetSubText(Array.GetValue("mapdata",CurrentY + 1),CurrentX,1) = 0 Then
CurrentY = CurrentY + 2
ElseIf Facing = 2 and Text.GetSubText(Array.GetValue("mapdata",CurrentY),CurrentX - 1,1) = 0 Then
CurrentX = CurrentX - 2
ElseIf Facing = 3 and Text.GetSubText(Array.GetValue("mapdata",CurrentY - 1),CurrentX,1) = 0 Then
CurrentY = CurrentY - 2
ElseIf Facing = 4 and Text.GetSubText(Array.GetValue("mapdata",CurrentY),CurrentX + 1,1) = 0 Then
CurrentX = CurrentX + 2
Else
HitWall()
EndIf
keyisupdated = "False"
EndIf
If key = "Back" Then
loop = "False"
keyisupdated = "False"
RestartMazeQuestion()
EndIf
If (key = "Escape") Then
Main = "False"
loop = "False"
EndIf
'draw the walls
GraphicsWindow.BrushColor = "White"
GraphicsWindow.PenWidth = 2
If fm = 0 Then
' immediate
If WallSection1 = 1 Then
GraphicsWindow.DrawLine(200,0,240,40)
GraphicsWindow.DrawLine(240,40,240,560)
GraphicsWindow.DrawLine(240,560,200,600)
EndIf
If WallSection1 = 2 Then
GraphicsWindow.DrawLine(200,40,240,40)
GraphicsWindow.DrawLine(240,40,240,560)
GraphicsWindow.DrawLine(240,560,200,560)
EndIf
If WallSection2 = 1 Then
GraphicsWindow.DrawLine(240,40,240,560)
GraphicsWindow.DrawLine(240,560,760,560)
GraphicsWindow.DrawLine(760,560,760,40)
GraphicsWindow.DrawLine(760,40,240,40)
fm = 4 'end wall drawing because you can't see any further
NoForward = "true"
EndIf
If WallSection3 = 1 Then
GraphicsWindow.DrawLine(800,0,760,40)
GraphicsWindow.DrawLine(760,40,760,560)
GraphicsWindow.DrawLine(760,560,800,600)
EndIf
If WallSection3 = 2 Then
GraphicsWindow.DrawLine(800,40,760,40)
GraphicsWindow.DrawLine(760,40,760,560)
GraphicsWindow.DrawLine(760,560,800,560)
EndIf
Sub HitWall
GraphicsWindow.BrushColor = "White"
GraphicsWindow.DrawText(483,295,"Ouch!")
'play sound to indicate hit wall
Sound.PlayAndWait("C:\WINDOWS\Media\Windows XP Battery Low.wav")
Sound.Stop("C:\WINDOWS\Media\Windows XP Battery Low.wav")
'[TODO]'s
'maybe put "OUCH" in maze view
'put message in information frame that you ran into a wall
'(IDEA: when secret walls are implemented, make some sound like magic or "swush" like sound when walking through secret wall)
'Note: be sure to clear both messages once a succesful Forward, left, right, or back move has been made.
EndSub
Sub ReadKey
key = GraphicsWindow.LastKey
keyisupdated = "True"
EndSub
Sub EraseMazeWalls
'erase walls from maze-view window
GraphicsWindow.BrushColor = "Black"
GraphicsWindow.PenWidth = 2
GraphicsWindow.FillRectangle(202,2,596,596)
'draw box around Maze-View window on the right
GraphicsWindow.PenColor = "White"
GraphicsWindow.PenWidth = 4
GraphicsWindow.DrawRectangle(200,0,600,600)
EndSub
Sub DisplayCurrentXY
'erase old coordinates
GraphicsWindow.BrushColor = "Gainsboro"
GraphicsWindow.FillRectangle(48,95,110,45)