Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #s = " "
- #p = "*"
- #wSize = 20
- OpenConsole(#s)
- EnableGraphicalConsole(#True)
- ConsoleCursor(0)
- #escape = 27
- #left = 37
- #up = 38
- #right = 39
- #down = 40
- Enumeration objects
- #none
- #tree
- #rock
- #water
- EndEnumeration
- Global Dim world.b(#wSize,#wSize)
- For i.b = 0 To #wSize
- For j.b = 0 To #wSize
- If Random(100) > 20
- world(i,j) = #none
- Else
- world(i,j) = Random(3,1)
- EndIf
- Next
- Next
- Global pX.b = Random(#wSize)
- Global pY.b = Random(#wSize)
- Procedure drawObject(x,y,isPlayer.b = #False)
- If isPlayer
- ConsoleColor(0,4)
- ConsoleLocate(pX,pY)
- Print(#p)
- Else
- Select world(x,y)
- Case #none
- ConsoleColor(0,2)
- Case #tree
- ConsoleColor(0,10)
- Case #rock
- ConsoleColor(0,7)
- Case #water
- ConsoleColor(0,9)
- EndSelect
- ConsoleLocate(x,y)
- Print(#s)
- EndIf
- EndProcedure
- For i.b = 0 To #wSize
- For j.b = 0 To #wSize
- drawObject(i,j)
- Next
- Next
- drawObject(pX,pY,#True)
- Repeat
- Inkey()
- Select RawKey()
- Case #left
- If pX - 1 >= 0 And world(pX-1,pY) = #none
- drawObject(pX,pY)
- pX - 1
- EndIf
- Case #right
- If pX + 1 <= #wSize And world(pX+1,pY) = #none
- drawObject(pX,pY)
- pX + 1
- EndIf
- Case #up
- If pY - 1 >= 0 And world(pX,pY-1) = #none
- drawObject(pX,pY)
- pY - 1
- EndIf
- Case #down
- If pY + 1 <= #wSize And world(pX,pY+1) = #none
- drawObject(pX,pY)
- pY + 1
- EndIf
- Case #escape
- Break
- Default
- Delay(20)
- EndSelect
- If RawKey()
- drawObject(pX,pY,#True)
- EndIf
- ForEver
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement