SHARE
TWEET

The Enchanted Forest

Archon May 22nd, 2011 189 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DECLARE SUB checkLoc ()
  2. DECLARE SUB drawTile (x, y)
  3. DECLARE SUB drawWizard ()
  4. DECLARE SUB drawMap ()
  5. DECLARE SUB generateMap ()
  6. DECLARE SUB drawInterface ()
  7.  
  8. SCREEN 7
  9. CLS
  10. RANDOMIZE TIMER
  11.  
  12. DIM SHARED map(0 TO 624)
  13. DIM SHARED TERRAINDOTS
  14. TERRAINDOTS = 10
  15. DIM SHARED terrainX(1 TO TERRAINDOTS)
  16. DIM SHARED terrainY(1 TO TERRAINDOTS)
  17. DIM SHARED WATER
  18. DIM SHARED GRASS
  19. WATER = 0
  20. GRASS = 1
  21. DIM SHARED wizardX
  22. DIM SHARED wizardY
  23. DIM SHARED initialDraw
  24. DIM SHARED validLoc
  25. validLoc = 1
  26.  
  27. CALL generateMap
  28. CALL drawInterface
  29. CALL drawMap
  30. CALL drawWizard
  31.  
  32. getKey:
  33. A$ = INKEY$
  34. IF A$ = "" THEN GOTO getKey
  35. IF A$ = "q" THEN
  36.     COLOR 8
  37.     END
  38. END IF
  39.  
  40. moveDist = 2
  41. IF A$ = "a" THEN
  42.     wizardX = wizardX - moveDist
  43.     IF wizardX < 0 THEN wizardX = 0
  44.     CALL checkLoc
  45.     IF validLoc = 0 THEN wizardX = wizardX + moveDist
  46. END IF
  47. IF A$ = "d" THEN
  48.     wizardX = wizardX + moveDist
  49.     IF wizardX > 191 THEN wizardX = 191
  50.     CALL checkLoc
  51.     IF validLoc = 0 THEN wizardX = wizardX - moveDist
  52. END IF
  53. IF A$ = "w" THEN
  54.     wizardY = wizardY - moveDist
  55.     IF wizardY < 0 THEN wizardY = 0
  56.     CALL checkLoc
  57.     IF validLoc = 0 THEN wizardY = wizardY + moveDist
  58. END IF
  59. IF A$ = "s" THEN
  60.     wizardY = wizardY + moveDist
  61.     IF wizardY > 191 THEN wizardY = 191
  62.     CALL checkLoc
  63.     IF validLoc = 0 THEN wizardY = wizardY - moveDist
  64. END IF
  65.  
  66. IF wizardX > 183 AND wizardY < 16 THEN
  67.     COLOR 15
  68.     LOCATE 7, 6
  69.     PRINT "                            "
  70.     LOCATE 8, 6
  71.     PRINT "     The wizard made it     "
  72.     LOCATE 9, 6
  73.     PRINT "                            "
  74.     LOCATE 10, 6
  75.     PRINT " to the enchanted forest!!! "
  76.     LOCATE 11, 6
  77.     PRINT "                            "
  78.     FOR i = 1 TO 7
  79.         BEEP
  80.     NEXT i
  81.     COLOR 8
  82.     WHILE INKEY$ <> "q"
  83.     WEND
  84.     END
  85. END IF
  86.  
  87. CALL drawInterface
  88. CALL drawMap
  89. 'FOR i = 1 TO 4
  90.     CALL drawWizard
  91. 'NEXT i
  92. GOTO getKey
  93.  
  94. SUB checkLoc
  95.  
  96.     'wizleft = wizardX - 2
  97.     'wizRight = wizardX + 2
  98.     'wizTop = wizardY - 2
  99.     'wizBottom = wizardY + 2
  100.    
  101.     xTile = INT((wizardX + 4) / 8)
  102.     yTile = INT((wizardY + 4) / 8)
  103.  
  104.  
  105.     IF map(xTile + 25 * yTile) = WATER THEN
  106.         validLoc = 0
  107.     ELSE
  108.         validLoc = 1
  109.     END IF
  110.  
  111. END SUB
  112.  
  113. SUB drawInterface
  114.     LOCATE 1, 27
  115.     COLOR 14
  116.     PRINT "The  Enchanted"
  117.     LOCATE 2, 27
  118.     COLOR 14
  119.     PRINT "    Forest"
  120.     LOCATE 8, 27
  121.     COLOR 12
  122.     PRINT "[stats]"
  123.     COLOR 8
  124.     LINE (204, 0)-(204, 200), 6
  125.     LINE (204, 20)-(320, 20), 6
  126. END SUB
  127.  
  128. SUB drawMap
  129.  
  130.     xTile = INT((wizardX + 4) / 8)
  131.     yTile = INT((wizardY + 4) / 8)
  132.  
  133.     FOR x = -4 TO 4
  134.         FOR y = -4 TO 4
  135.             IF y = -4 AND (x = -4 OR x = -3 OR x = 3 OR x = 4) THEN GOTO skip
  136.             IF y = -3 AND (x = -4 OR x = 4) THEN GOTO skip
  137.             IF y = 3 AND (x = -4 OR x = 4) THEN GOTO skip
  138.             IF y = 4 AND (x = -4 OR x = -3 OR x = 3 OR x = 4) THEN GOTO skip
  139.  
  140.             CALL drawTile(xTile + x, yTile + y)
  141.     skip:
  142.         NEXT y
  143.     NEXT x
  144.  
  145. END SUB
  146.  
  147. SUB drawTile (x, y)
  148.  
  149.     IF x < 0 OR x > 24 OR y < 0 OR y > 24 THEN EXIT SUB
  150.  
  151.     n = y * 25 + x
  152.     px = x * 8
  153.     py = y * 8
  154.     backColor = 0
  155.     foreColor = 0
  156.     numDots = 0
  157.     altForeColor = 0
  158.     numAltDots = 0
  159.     SELECT CASE map(n)
  160.     CASE GRASS
  161.         backColor = 2
  162.         foreColor = 6
  163.     CASE WATER
  164.         backColor = 1
  165.         foreColor = 9
  166.     END SELECT
  167.     LINE (px, py)-(px + 7, py + 7), backColor, BF
  168.     FOR i = 1 TO TERRAINDOTS
  169.         PSET (terrainX(i) + px, terrainY(i) + py), foreColor
  170.     NEXT i
  171.  
  172. END SUB
  173.  
  174. SUB drawWizard
  175.     x = wizardX
  176.     y = wizardY
  177.    
  178.     'hat
  179.     PSET (x, y - 12), 5
  180.     DRAW "f1 nu4 r1 nu7 r1 nu10 r1 nu7 r1 nu4 e1"
  181.    
  182.     'star
  183.     PSET (x + 1, y - 14), 14
  184.     DRAW "r2 bh1 d2"
  185.  
  186.     'hair and beard
  187.     PSET (x + 1, y - 10), 15
  188.     DRAW "d4 l1 d1 be5 d4 l3 d1 r1 nr1 d1 nl1 d3"
  189.  
  190.     'moustache
  191.     PSET (x + 2, y - 6), 7
  192.     DRAW "u2 r2 d2"
  193.  
  194.     'eyes
  195.     PSET (x + 2, y - 9), 11
  196.     PSET (x + 4, y - 9), 11
  197.  
  198.     'face
  199.     PSET (x + 2, y - 10), 12
  200.     DRAW "f1 e1 l1"
  201.     PSET (x + 3, y - 7), 12
  202.  
  203.     'robe
  204.     PSET (x, y - 4), 5
  205.     DRAW "nd8 be1 d11 bf1 nu10 br1 nu7 br1 u11 be1 d12 be1 nu12 be1 bu1 u8"
  206.  
  207.     'boots
  208.     PSET (x + 1, y + 7), 0
  209.     DRAW "u1"
  210.     PSET (x + 6, y + 7), 0
  211.     DRAW "u1"
  212.  
  213.     'moon and stars
  214.     PSET (x + 6, y - 1), 14
  215.     DRAW "d2 l1 d1 l2"
  216.     PSET (x, y), 14
  217.     DRAW "r2 bh1 d2"
  218.     PSET (x + 2, y + 5), 14
  219.     DRAW "r2 bh1 d2"
  220.  
  221. END SUB
  222.  
  223. SUB generateMap
  224.     FOR i = 0 TO 624
  225.         map(i) = INT(RND * 4)
  226.         IF map(i) > 0 THEN
  227.             map(i) = GRASS
  228.         ELSE
  229.             map(i) = WATER
  230.         END IF
  231.     NEXT i
  232.  
  233.     'place wizard
  234.     map(525 + 0) = GRASS
  235.     map(525 + 1) = GRASS
  236.     map(550 + 0) = GRASS
  237.     map(550 + 1) = GRASS
  238.     map(550 + 2) = GRASS
  239.     map(575 + 0) = GRASS
  240.     map(575 + 1) = GRASS
  241.     map(575 + 2) = GRASS
  242.     map(575 + 3) = GRASS
  243.     map(600 + 0) = GRASS
  244.     map(600 + 1) = GRASS
  245.     map(600 + 2) = GRASS
  246.     map(600 + 3) = GRASS
  247.  
  248.     wizardX = 4
  249.     wizardY = 188
  250.  
  251.  
  252.     'terrain pattern
  253.     FOR i = 1 TO TERRAINDOTS
  254.         terrainX(i) = INT(RND * 8)
  255.         terrainY(i) = INT(RND * 8)
  256.     NEXT i
  257.  
  258. END SUB
RAW Paste Data
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top