Advertisement
deseven

4kgame

May 28th, 2015
1,011
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #s = " "
  2. #p = "*"
  3. #wSize = 20
  4. OpenConsole(#s)
  5. EnableGraphicalConsole(#True)
  6. ConsoleCursor(0)
  7.  
  8. #escape = 27
  9. #left = 37
  10. #up = 38
  11. #right = 39
  12. #down = 40
  13.  
  14. Enumeration objects
  15.   #none
  16.   #tree
  17.   #rock
  18.   #water
  19. EndEnumeration
  20.  
  21. Global Dim world.b(#wSize,#wSize)
  22. For i.b = 0 To #wSize
  23.   For j.b = 0 To #wSize
  24.     If Random(100) > 20
  25.       world(i,j) = #none
  26.     Else
  27.       world(i,j) = Random(3,1)
  28.     EndIf
  29.   Next
  30. Next
  31.  
  32. Global pX.b = Random(#wSize)
  33. Global pY.b = Random(#wSize)
  34.  
  35. Procedure drawObject(x,y,isPlayer.b = #False)
  36.   If isPlayer
  37.     ConsoleColor(0,4)
  38.     ConsoleLocate(pX,pY)
  39.     Print(#p)
  40.   Else
  41.     Select world(x,y)
  42.       Case #none
  43.         ConsoleColor(0,2)
  44.       Case #tree
  45.         ConsoleColor(0,10)
  46.       Case #rock
  47.         ConsoleColor(0,7)
  48.       Case #water
  49.         ConsoleColor(0,9)
  50.     EndSelect
  51.     ConsoleLocate(x,y)
  52.     Print(#s)
  53.   EndIf
  54. EndProcedure
  55.  
  56. For i.b = 0 To #wSize
  57.   For j.b = 0 To #wSize
  58.     drawObject(i,j)
  59.   Next
  60. Next
  61. drawObject(pX,pY,#True)
  62.  
  63. Repeat
  64.   Inkey()
  65.   Select RawKey()
  66.     Case #left
  67.       If pX - 1 >= 0 And world(pX-1,pY) = #none
  68.         drawObject(pX,pY)
  69.         pX - 1
  70.       EndIf
  71.     Case #right
  72.       If pX + 1 <= #wSize And world(pX+1,pY) = #none
  73.         drawObject(pX,pY)
  74.         pX + 1
  75.       EndIf
  76.     Case #up
  77.       If pY - 1 >= 0 And world(pX,pY-1) = #none
  78.         drawObject(pX,pY)
  79.         pY - 1
  80.       EndIf
  81.     Case #down
  82.       If pY + 1 <= #wSize And world(pX,pY+1) = #none
  83.         drawObject(pX,pY)
  84.         pY + 1
  85.       EndIf
  86.     Case #escape
  87.       Break
  88.     Default
  89.       Delay(20)
  90.   EndSelect
  91.   If RawKey()
  92.     drawObject(pX,pY,#True)
  93.   EndIf
  94. ForEver
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement