hi here is an old test of an old text adventure game in purebasic - you move around with arrows keys...
EnableExplicit
#Window_Main = 0
#Screen_Width = 800
#Screen_Height = 600
Structure location
Array compass.s(3)
location.s
Array directions.s(3)
Array way_map.i(3)
EndStructure
Dim places.location(6)
Define.s r
Define.i i, ii
places(0)\way_map(0) = -1
places(0)\way_map(1) = -1
places(0)\way_map(2) = 1
places(0)\way_map(3) = -1
places(1)\way_map(0) = 0
places(1)\way_map(1) = -1
places(1)\way_map(2) = 2
places(1)\way_map(3) = -1
places(2)\way_map(0) = 1
places(2)\way_map(1) = -1
places(2)\way_map(2) = 3
places(2)\way_map(3) = -1
places(3)\way_map(0) = 2
places(3)\way_map(1) = -1
places(3)\way_map(2) = 4
places(3)\way_map(3) = -1
places(4)\way_map(0) = 3
places(4)\way_map(1) = -1
places(4)\way_map(2) = 5
places(4)\way_map(3) = -1
places(5)\way_map(0) = 4
places(5)\way_map(1) = -1
places(5)\way_map(2) = 6
places(5)\way_map(3) = -1
places(6)\way_map(0) = 5
places(6)\way_map(1) = -1
places(6)\way_map(2) = -1
places(6)\way_map(3) = -1
Procedure cprint(row.i, text.s)
DrawText((#Screen_Width - TextWidth(text)) / 2, row , text, #White)
EndProcedure
Restore compass
For i = 0 To 3
Read.s r
places(0)\compass(i) = r
Next
Restore locations
For i = 0 To 6
Read.s r
places(i)\location = r
Next
Restore directions
For i = 0 To 6
For ii = 0 To 3
Read.s r
places(i)\directions(ii) = r
Next
Next
InitKeyboard()
InitSprite()
OpenWindow(#Window_Main, 0, 0, #Screen_Width, #Screen_Height, "TEST", #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(#Window_Main), 0, 0, #Screen_Width, #Screen_Height, #True, 0, 0)
Procedure main(Array places.location(1))
Define k.s
Define.i x, z
Repeat
Repeat
Define Event = WindowEvent()
Select Event
Case #PB_Event_CloseWindow
End
EndSelect
Until Event = 0
ClearScreen(#Black)
If x < 0 : x = 0 :EndIf
If x > 6 : x = 6 :EndIf
If z > 3 : z = 0 :EndIf
If z < 0 : z = 3 :EndIf
If StartDrawing(ScreenOutput())
cprint(20, places(0)\compass(z))
cprint(40, places(x)\location)
cprint(100, places(x)\directions(z))
StopDrawing()
EndIf
ExamineKeyboard()
If KeyboardReleased(#PB_Key_Up)
; x = x + 1
If places(x)\way_map(z) <> -1
x = places(x)\way_map(z)
EndIf
EndIf
; If KeyboardReleased(#PB_Key_Down)
; x = x - 1
; EndIf
If KeyboardReleased(#PB_Key_Right)
z = z + 1
EndIf
If KeyboardReleased(#PB_Key_Left)
z = z - 1
EndIf
ExamineKeyboard()
FlipBuffers()
Delay(3)
Until KeyboardPushed(#PB_Key_Escape)
EndProcedure
main(places())
DataSection
compass:
Data.s "NORTH", "EAST", "SOUTH", "WEST"
locations:
Data.s "CELL ROOM", "CORADOOR", "HALLWAY", "CHAMBER", "ENTRANCE HALL", "GATEWAY", "OUTSIDE"
directions:
Data.s "a wall with bar windows"
Data.s "a bed with a chair and a table"
Data.s "a cell door"
Data.s "a brick wall"
Data.s "a cell door"
Data.s "a long wall"
Data.s "a nerrow path with stairs"
Data.s "a high wall of bricks"
Data.s "a narrow path with stairs"
Data.s "a wall with mirrors"
Data.s "an open door with light from it"
Data.s "a wall with lots of pictures on it"
Data.s "an open door"
Data.s "a large chamber with windows"
Data.s "a long path"
Data.s "a brick wall"
Data.s "a long path"
Data.s "a large entarnce hall full of sheles with books"
Data.s "a gate is seen far in the next room"
Data.s "a brick wall with windows"
Data.s "entery to a hall"
Data.s "locked doors"
Data.s "a gate to the outside"
Data.s "a long tunnle with a locked door"
Data.s "a gate to enter a castle"
Data.s "green fileds in bright sun light"
Data.s "a road to a far distenced village"
Data.s "a forest in the distence"
EndDataSection
; IDE Options = PureBasic 5.73 LTS (Windows - x64)
; CursorPosition = 94
; FirstLine = 72
; Folding = -
; EnableXP