i've been working today on a small demo of a game base or game engine for an adventure game - i don't use graphics or sound just text...
you move around with the key arrows and exit with escape key...
code criticism and code review are welcomed
p.s. - i hope to add some sort of a open-direction(that you can pass through) and a closed direction (that you cannot pass through)
Code: Select all
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
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
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
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