QB64.org Forum

Active Forums => Programs => Topic started by: SierraKen on October 23, 2020, 09:12:51 pm

Title: Find The Gold!
Post by: SierraKen on October 23, 2020, 09:12:51 pm
This is my first game made using Felippe's moving map camera code. Use your arrow keys to move your cowboy around the different land areas, trees, and lakes, to find the gold bars. If you find 20 of them you advance to the next level. Level 1 starts out with 300 seconds to finish and every level it decreases by 5 seconds. After level 20 you win the game. Instructions are in the Title bar and the game is paused when it loads and starts when you press any key and your cowboy appears on screen. You lose if your time runs out and you still have gold bars left to find on that level.
The maps on each level are randomly generated.

*NOTE: Don't use the code below, it has one error I accidentally made where you can't go past level 1 LOL. Scroll down to get the fixed code. Sorry about that!

Code: QB64: [Select]
  1. 'Find the Gold! by SierraKen
  2. 'October 23, 2020
  3. 'Thanks for the great mapping code by FellipeHeitor and help from B+!
  4. 'Additions: Body, Arms, and Legs. Levels and 20 gold per level. Larger land area sizes. Lakes and Trees. 20 Level limit.
  5.  
  6. SCREEN _NEWIMAGE(1000, 800, 32)
  7.  
  8. TYPE object
  9.     x AS SINGLE
  10.     y AS SINGLE
  11.  
  12. DIM SHARED player AS object
  13. DIM SHARED camera AS object
  14. DIM playerSpeed AS SINGLE
  15.  
  16. _TITLE "Find The Gold! Use the arrow keys to find 20 gold bars per level. Every level will have a shorter time. After Level 20 you win the game."
  17.  
  18. start:
  19. score = 0
  20. level = 1
  21. player.x = _WIDTH / 2
  22. player.y = _HEIGHT / 2
  23.  
  24. map = _NEWIMAGE(_WIDTH * 7, _HEIGHT * 7, 32)
  25.  
  26. _DEST map
  27. PAINT (2, 2), _RGB32(0, 200, 0)
  28.  
  29. 'Land Areas
  30. FOR blocks = 1 TO 400
  31.     blocks:
  32.     xx = (RND * _WIDTH)
  33.     yy = (RND * _HEIGHT)
  34.     sz = INT(RND * 300) + 50
  35.     blockcolors:
  36.     c1 = INT(RND * 155) + 100
  37.     c2 = INT(RND * 155) + 100
  38.     c3 = INT(RND * 155) + 100
  39.     IF c1 = 255 AND c2 = 255 AND c3 = 128 THEN GOTO blockcolors:
  40.     LINE (xx, yy)-(xx + sz, yy + sz), _RGB32(c1, c2, c3), BF
  41.     IF POINT(_WIDTH / 2, _HEIGHT / 2) = _RGB32(c1, c2, c3) THEN GOTO blocks:
  42.  
  43. 'Lakes
  44. FOR lakes = 1 TO 10
  45.     w = RND
  46.     h = RND
  47.     sze = (RND * 150) + 50
  48.     FOR sz = .25 TO sze STEP .25
  49.         CIRCLE (w * _WIDTH, h * _HEIGHT), sz, _RGB32(0, 0, 255)
  50.     NEXT sz
  51. NEXT lakes
  52.  
  53. 'Trees
  54. FOR trees = 1 TO 400
  55.     tx = RND
  56.     tx = tx * _WIDTH
  57.     ty = RND
  58.     ty = ty * _HEIGHT
  59.     tsz = (RND * 40) + 10
  60.     LINE (tx, ty)-(tx, ty + tsz + 5), _RGB32(188, 127, 127)
  61.     FOR branches = ty TO ty + tsz STEP 3
  62.         LINE (tx, branches)-(tx - 10, branches + 5), _RGB32(127, 255, 127)
  63.         LINE (tx, branches)-(tx + 10, branches + 5), _RGB32(127, 255, 127)
  64.     NEXT branches
  65. NEXT trees
  66.  
  67.  
  68. 'Place Gold
  69. FOR gold = 1 TO 20
  70.     w2 = INT(RND * _WIDTH) - 15
  71.     h2 = INT(RND * _HEIGHT) - 10
  72.     IF w2 < 15 THEN w2 = 15
  73.     IF h2 < 10 THEN h2 = 10
  74.  
  75.     'Gold
  76.     COLOR _RGB32(0, 0, 0), _RGB32(255, 255, 128)
  77.     _PRINTSTRING (w2, h2), "GOLD"
  78. NEXT gold
  79.  
  80.  
  81.  
  82. playerSpeed = 10
  83.  
  84. CONST keyUP = 18432
  85. CONST keyDOWN = 20480
  86. CONST keyLEFT = 19200
  87. CONST keyRIGHT = 19712
  88. CONST keyESC = 27
  89. _PUTIMAGE (camera.x, camera.y), map
  90.  
  91. LOCATE 10, 55: PRINT "Press Any Key To Begin."
  92.  
  93. pause:
  94. a$ = INKEY$
  95. IF a$ <> "" THEN GOTO begin:
  96. GOTO pause:
  97.  
  98. begin:
  99.  
  100. seconds = INT(TIMER)
  101.     CLS
  102.     leveltime = level * 5
  103.     gametime = (305 - leveltime) - (INT(TIMER) - seconds)
  104.     _PUTIMAGE (camera.x, camera.y), map
  105.     LOCATE 1, 1: PRINT "Time Left: "; gametime
  106.     IF gametime < 1 THEN GOTO done:
  107.     IF _KEYDOWN(keyUP) THEN
  108.         player.y = player.y - playerSpeed
  109.         t = t + 1
  110.     END IF
  111.     IF _KEYDOWN(keyDOWN) THEN
  112.         player.y = player.y + playerSpeed
  113.         t = t + 1
  114.     END IF
  115.     IF _KEYDOWN(keyLEFT) THEN
  116.         player.x = player.x - playerSpeed
  117.         t = t + 1
  118.     END IF
  119.     IF _KEYDOWN(keyRIGHT) THEN
  120.         player.x = player.x + playerSpeed
  121.         t = t + 1
  122.     END IF
  123.     IF _KEYDOWN(keyESC) THEN END
  124.     IF player.x < 0 THEN player.x = 0
  125.     IF player.x > _WIDTH(map) THEN player.x = _WIDTH(map)
  126.     IF player.y < 0 THEN player.y = 0
  127.     IF player.y > _HEIGHT(map) THEN player.y = _HEIGHT(map)
  128.  
  129.     adjustCamera
  130.  
  131.     'Draw Head
  132.     FOR sz = .25 TO 10 STEP .25
  133.         CIRCLE (player.x + camera.x, player.y + camera.y), sz, _RGB32(255, 166, 127)
  134.     NEXT sz
  135.     'Draw Smile
  136.     CIRCLE (player.x + camera.x, player.y + camera.y + 2), 7, _RGB32(255, 0, 0), _PI, 2 * _PI, .5
  137.     'Draw Eyes
  138.     CIRCLE (player.x + camera.x - 4, player.y + camera.y - 2), 1, _RGB32(0, 0, 255)
  139.     CIRCLE (player.x + camera.x + 4, player.y + camera.y - 2), 1, _RGB32(0, 0, 255)
  140.     'hat
  141.     LINE (player.x + camera.x - 10, player.y + camera.y - 10)-(player.x + camera.x + 10, player.y + camera.y - 9), _RGB32(155, 0, 0), BF
  142.     LINE (player.x + camera.x - 5, player.y + camera.y - 9)-(player.x + camera.x + 5, player.y + camera.y - 15), _RGB32(155, 0, 0), BF
  143.     'body
  144.     LINE (player.x + camera.x, player.y + camera.y + 10)-(player.x + camera.x, player.y + camera.y + 20), _RGB32(155, 0, 0)
  145.  
  146.     IF t > 7 THEN t = 0
  147.  
  148.     'rest of body
  149.     IF t = 0 THEN
  150.         'left arm
  151.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 15, player.y + camera.y + 25), _RGB32(155, 0, 0)
  152.         'right arm
  153.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 15, player.y + camera.y + 25), _RGB32(155, 0, 0)
  154.         'left leg
  155.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 15, player.y + camera.y + 35), _RGB32(155, 0, 0)
  156.         'right leg
  157.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 15, player.y + camera.y + 35), _RGB32(155, 0, 0)
  158.     END IF
  159.  
  160.     IF t = 1 OR t = 7 THEN
  161.         'left arm
  162.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 11, player.y + camera.y + 25), _RGB32(155, 0, 0)
  163.         'right arm
  164.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 11, player.y + camera.y + 25), _RGB32(155, 0, 0)
  165.         'left leg
  166.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 11, player.y + camera.y + 35), _RGB32(155, 0, 0)
  167.         'right leg
  168.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 11, player.y + camera.y + 35), _RGB32(155, 0, 0)
  169.     END IF
  170.  
  171.     IF t = 2 OR t = 6 THEN
  172.         'left arm
  173.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 9, player.y + camera.y + 24), _RGB32(155, 0, 0)
  174.         'right arm
  175.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 9, player.y + camera.y + 24), _RGB32(155, 0, 0)
  176.         'left leg
  177.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 9, player.y + camera.y + 35), _RGB32(155, 0, 0)
  178.         'right leg
  179.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 9, player.y + camera.y + 35), _RGB32(155, 0, 0)
  180.     END IF
  181.  
  182.     IF t = 3 OR t = 5 THEN
  183.         'left arm
  184.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 7, player.y + camera.y + 24), _RGB32(155, 0, 0)
  185.         'right arm
  186.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 7, player.y + camera.y + 24), _RGB32(155, 0, 0)
  187.         'left leg
  188.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 7, player.y + camera.y + 35), _RGB32(155, 0, 0)
  189.         'right leg
  190.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 7, player.y + camera.y + 35), _RGB32(155, 0, 0)
  191.     END IF
  192.  
  193.     IF t = 4 THEN
  194.         'left arm
  195.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 5, player.y + camera.y + 23), _RGB32(155, 0, 0)
  196.         'right arm
  197.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 5, player.y + camera.y + 23), _RGB32(155, 0, 0)
  198.         'left leg
  199.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 5, player.y + camera.y + 35), _RGB32(155, 0, 0)
  200.         'right leg
  201.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 5, player.y + camera.y + 35), _RGB32(155, 0, 0)
  202.     END IF
  203.  
  204.  
  205.     FOR check = -15 TO 15
  206.         IF POINT(player.x + check, player.y + check) = _RGB32(255, 255, 128) THEN
  207.             _DEST map
  208.             FOR sz = .2 TO 35 STEP .2
  209.                 CIRCLE (player.x + check, player.y + check), sz, _RGB32(127, 127, 127)
  210.             NEXT sz
  211.             GOSUB findgold:
  212.         END IF
  213.         IF POINT(player.x + check, player.y - check) = _RGB32(255, 255, 128) THEN
  214.             _DEST map
  215.             FOR sz = .2 TO 35 STEP .2
  216.                 CIRCLE (player.x + check, player.y - check), sz, _RGB32(127, 127, 127)
  217.             NEXT sz
  218.             GOSUB findgold:
  219.         END IF
  220.         IF POINT(player.x - check, player.y + check) = _RGB32(255, 255, 128) THEN
  221.             _DEST map
  222.             FOR sz = .2 TO 35 STEP .2
  223.                 CIRCLE (player.x - check, player.y + check), sz, _RGB32(127, 127, 127)
  224.             NEXT sz
  225.             GOSUB findgold:
  226.         END IF
  227.     NEXT check
  228.     _DISPLAY
  229.     _LIMIT 60
  230.  
  231. findgold:
  232. FOR snd = 800 TO 400 STEP -100
  233.     SOUND snd, .5
  234. NEXT snd
  235. score = score + 100
  236. score$ = STR$(score)
  237. level$ = STR$(level)
  238. _TITLE "Level: " + level$ + "   Score: " + score$
  239. IF score / 2000 = INT(score / 2000) THEN
  240.     level = level + 1
  241.     level$ = STR$(level)
  242.     _TITLE "Level: " + level$ + "   Score: " + score$
  243.     IF level = 21 THEN GOTO win:
  244.     GOTO start:
  245.  
  246. done:
  247. LOCATE 10, 55: PRINT "G A M E     O V E R"
  248. FOR snd = 450 TO 150 STEP -25
  249.     SOUND snd, .5
  250. NEXT snd
  251. LOCATE 13, 55: PRINT "Again (Y/N)?"
  252. ag:
  253. ag$ = INKEY$
  254. IF ag$ = "y" OR ag$ = "Y" THEN GOTO start:
  255. IF ag$ = "n" OR ag$ = "N" THEN END
  256. GOTO ag:
  257.  
  258. win:
  259. LOCATE 10, 55: PRINT "G A M E     W O N ! ! ! ! ! ! !"
  260. FOR snd = 450 TO 150 STEP -25
  261.     SOUND snd, .5
  262. NEXT snd
  263. LOCATE 13, 55: PRINT "Again (Y/N)?"
  264. ag2:
  265. ag$ = INKEY$
  266. IF ag$ = "y" OR ag$ = "Y" THEN GOTO start:
  267. IF ag$ = "n" OR ag$ = "N" THEN END
  268. GOTO ag2:
  269.  
  270. 'Thanks to FelippeHeitor for this Sub and the camera code above.
  271. SUB adjustCamera
  272.     IF player.x + camera.x > _WIDTH / 2 OR player.x + camera.x < _WIDTH / 2 THEN
  273.         camera.x = _WIDTH / 2 - player.x
  274.     END IF
  275.     IF camera.x > 0 THEN camera.x = 0
  276.     IF camera.x < -(_WIDTH(map) - _WIDTH) THEN camera.x = -(_WIDTH(map) - _WIDTH)
  277.  
  278.     IF player.y + camera.y > _HEIGHT / 2 OR player.y + camera.y < _HEIGHT / 2 THEN
  279.         camera.y = _HEIGHT / 2 - player.y
  280.     END IF
  281.     IF camera.y > 0 THEN camera.y = 0
  282.     IF camera.y < -(_HEIGHT(map) - _HEIGHT) THEN camera.y = -(_HEIGHT(map) - _HEIGHT)
  283.  


 
Title: Re: Find The Gold!
Post by: SierraKen on October 23, 2020, 09:17:21 pm
If you want to learn more about the map and camera movement as well as another example Felippe did using online players with it,
go here: https://www.qb64.org/forum/index.php?topic=3139.0 (https://www.qb64.org/forum/index.php?topic=3139.0)
Title: Re: Find The Gold!
Post by: SierraKen on October 23, 2020, 10:43:40 pm
Here is the fixed code that lets you go past level 1. This is what happens when a couple weeks of not programming does, it gets me rusty. :) Sorry about that guys.

Code: QB64: [Select]
  1. 'Find the Gold! by SierraKen
  2. 'October 23, 2020
  3. 'Thanks for the great mapping code by FellipeHeitor and help from B+!
  4. 'Additions: Body, Arms, and Legs. Levels and 20 gold per level. Larger land area sizes. Lakes and Trees. 20 Level limit.
  5.  
  6.  
  7. SCREEN _NEWIMAGE(1000, 800, 32)
  8.  
  9. TYPE object
  10.     x AS SINGLE
  11.     y AS SINGLE
  12.  
  13. DIM SHARED player AS object
  14. DIM SHARED camera AS object
  15. DIM playerSpeed AS SINGLE
  16.  
  17. _TITLE "Find The Gold! Use the arrow keys to find 20 gold bars per level. Every level will have a shorter time. After Level 20 you win the game."
  18.  
  19. start:
  20. score = 0
  21. level = 1
  22.  
  23. start2:
  24. player.x = _WIDTH / 2
  25. player.y = _HEIGHT / 2
  26.  
  27. map = _NEWIMAGE(_WIDTH * 7, _HEIGHT * 7, 32)
  28.  
  29. _DEST map
  30. PAINT (2, 2), _RGB32(0, 200, 0)
  31.  
  32. 'Land Areas
  33. FOR blocks = 1 TO 400
  34.     blocks:
  35.     xx = (RND * _WIDTH)
  36.     yy = (RND * _HEIGHT)
  37.     sz = INT(RND * 300) + 50
  38.     blockcolors:
  39.     c1 = INT(RND * 155) + 100
  40.     c2 = INT(RND * 155) + 100
  41.     c3 = INT(RND * 155) + 100
  42.     IF c1 = 255 AND c2 = 255 AND c3 = 128 THEN GOTO blockcolors:
  43.     LINE (xx, yy)-(xx + sz, yy + sz), _RGB32(c1, c2, c3), BF
  44.     IF POINT(_WIDTH / 2, _HEIGHT / 2) = _RGB32(c1, c2, c3) THEN GOTO blocks:
  45.  
  46. 'Lakes
  47. FOR lakes = 1 TO 10
  48.     w = RND
  49.     h = RND
  50.     sze = (RND * 150) + 50
  51.     FOR sz = .25 TO sze STEP .25
  52.         CIRCLE (w * _WIDTH, h * _HEIGHT), sz, _RGB32(0, 0, 255)
  53.     NEXT sz
  54. NEXT lakes
  55.  
  56. 'Trees
  57. FOR trees = 1 TO 400
  58.     tx = RND
  59.     tx = tx * _WIDTH
  60.     ty = RND
  61.     ty = ty * _HEIGHT
  62.     tsz = (RND * 40) + 10
  63.     LINE (tx, ty)-(tx, ty + tsz + 5), _RGB32(188, 127, 127)
  64.     FOR branches = ty TO ty + tsz STEP 3
  65.         LINE (tx, branches)-(tx - 10, branches + 5), _RGB32(127, 255, 127)
  66.         LINE (tx, branches)-(tx + 10, branches + 5), _RGB32(127, 255, 127)
  67.     NEXT branches
  68. NEXT trees
  69.  
  70.  
  71. 'Place Gold
  72. FOR gold = 1 TO 20
  73.     w2 = INT(RND * _WIDTH) - 15
  74.     h2 = INT(RND * _HEIGHT) - 10
  75.     IF w2 < 15 THEN w2 = 15
  76.     IF h2 < 10 THEN h2 = 10
  77.  
  78.     'Gold
  79.     COLOR _RGB32(0, 0, 0), _RGB32(255, 255, 128)
  80.     _PRINTSTRING (w2, h2), "GOLD"
  81. NEXT gold
  82.  
  83.  
  84.  
  85. playerSpeed = 10
  86.  
  87. CONST keyUP = 18432
  88. CONST keyDOWN = 20480
  89. CONST keyLEFT = 19200
  90. CONST keyRIGHT = 19712
  91. CONST keyESC = 27
  92. _PUTIMAGE (camera.x, camera.y), map
  93.  
  94. LOCATE 10, 55: PRINT "Press Any Key To Begin."
  95.  
  96. pause:
  97. a$ = INKEY$
  98. IF a$ <> "" THEN GOTO begin:
  99. GOTO pause:
  100.  
  101. begin:
  102.  
  103. seconds = INT(TIMER)
  104.     CLS
  105.     leveltime = level * 5
  106.     gametime = (305 - leveltime) - (INT(TIMER) - seconds)
  107.     _PUTIMAGE (camera.x, camera.y), map
  108.     LOCATE 1, 1: PRINT "Time Left: "; gametime
  109.     IF gametime < 1 THEN GOTO done:
  110.     IF _KEYDOWN(keyUP) THEN
  111.         player.y = player.y - playerSpeed
  112.         t = t + 1
  113.     END IF
  114.     IF _KEYDOWN(keyDOWN) THEN
  115.         player.y = player.y + playerSpeed
  116.         t = t + 1
  117.     END IF
  118.     IF _KEYDOWN(keyLEFT) THEN
  119.         player.x = player.x - playerSpeed
  120.         t = t + 1
  121.     END IF
  122.     IF _KEYDOWN(keyRIGHT) THEN
  123.         player.x = player.x + playerSpeed
  124.         t = t + 1
  125.     END IF
  126.     IF _KEYDOWN(keyESC) THEN END
  127.     IF player.x < 0 THEN player.x = 0
  128.     IF player.x > _WIDTH(map) THEN player.x = _WIDTH(map)
  129.     IF player.y < 0 THEN player.y = 0
  130.     IF player.y > _HEIGHT(map) THEN player.y = _HEIGHT(map)
  131.  
  132.     adjustCamera
  133.  
  134.     'Draw Head
  135.     FOR sz = .25 TO 10 STEP .25
  136.         CIRCLE (player.x + camera.x, player.y + camera.y), sz, _RGB32(255, 166, 127)
  137.     NEXT sz
  138.     'Draw Smile
  139.     CIRCLE (player.x + camera.x, player.y + camera.y + 2), 7, _RGB32(255, 0, 0), _PI, 2 * _PI, .5
  140.     'Draw Eyes
  141.     CIRCLE (player.x + camera.x - 4, player.y + camera.y - 2), 1, _RGB32(0, 0, 255)
  142.     CIRCLE (player.x + camera.x + 4, player.y + camera.y - 2), 1, _RGB32(0, 0, 255)
  143.     'hat
  144.     LINE (player.x + camera.x - 10, player.y + camera.y - 10)-(player.x + camera.x + 10, player.y + camera.y - 9), _RGB32(155, 0, 0), BF
  145.     LINE (player.x + camera.x - 5, player.y + camera.y - 9)-(player.x + camera.x + 5, player.y + camera.y - 15), _RGB32(155, 0, 0), BF
  146.     'body
  147.     LINE (player.x + camera.x, player.y + camera.y + 10)-(player.x + camera.x, player.y + camera.y + 20), _RGB32(155, 0, 0)
  148.  
  149.     IF t > 7 THEN t = 0
  150.  
  151.     'rest of body
  152.     IF t = 0 THEN
  153.         'left arm
  154.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 15, player.y + camera.y + 25), _RGB32(155, 0, 0)
  155.         'right arm
  156.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 15, player.y + camera.y + 25), _RGB32(155, 0, 0)
  157.         'left leg
  158.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 15, player.y + camera.y + 35), _RGB32(155, 0, 0)
  159.         'right leg
  160.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 15, player.y + camera.y + 35), _RGB32(155, 0, 0)
  161.     END IF
  162.  
  163.     IF t = 1 OR t = 7 THEN
  164.         'left arm
  165.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 11, player.y + camera.y + 25), _RGB32(155, 0, 0)
  166.         'right arm
  167.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 11, player.y + camera.y + 25), _RGB32(155, 0, 0)
  168.         'left leg
  169.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 11, player.y + camera.y + 35), _RGB32(155, 0, 0)
  170.         'right leg
  171.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 11, player.y + camera.y + 35), _RGB32(155, 0, 0)
  172.     END IF
  173.  
  174.     IF t = 2 OR t = 6 THEN
  175.         'left arm
  176.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 9, player.y + camera.y + 24), _RGB32(155, 0, 0)
  177.         'right arm
  178.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 9, player.y + camera.y + 24), _RGB32(155, 0, 0)
  179.         'left leg
  180.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 9, player.y + camera.y + 35), _RGB32(155, 0, 0)
  181.         'right leg
  182.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 9, player.y + camera.y + 35), _RGB32(155, 0, 0)
  183.     END IF
  184.  
  185.     IF t = 3 OR t = 5 THEN
  186.         'left arm
  187.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 7, player.y + camera.y + 24), _RGB32(155, 0, 0)
  188.         'right arm
  189.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 7, player.y + camera.y + 24), _RGB32(155, 0, 0)
  190.         'left leg
  191.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 7, player.y + camera.y + 35), _RGB32(155, 0, 0)
  192.         'right leg
  193.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 7, player.y + camera.y + 35), _RGB32(155, 0, 0)
  194.     END IF
  195.  
  196.     IF t = 4 THEN
  197.         'left arm
  198.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 5, player.y + camera.y + 23), _RGB32(155, 0, 0)
  199.         'right arm
  200.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 5, player.y + camera.y + 23), _RGB32(155, 0, 0)
  201.         'left leg
  202.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 5, player.y + camera.y + 35), _RGB32(155, 0, 0)
  203.         'right leg
  204.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 5, player.y + camera.y + 35), _RGB32(155, 0, 0)
  205.     END IF
  206.  
  207.  
  208.     FOR check = -15 TO 15
  209.         IF POINT(player.x + check, player.y + check) = _RGB32(255, 255, 128) THEN
  210.             _DEST map
  211.             FOR sz = .2 TO 35 STEP .2
  212.                 CIRCLE (player.x + check, player.y + check), sz, _RGB32(127, 127, 127)
  213.             NEXT sz
  214.             GOSUB findgold:
  215.         END IF
  216.         IF POINT(player.x + check, player.y - check) = _RGB32(255, 255, 128) THEN
  217.             _DEST map
  218.             FOR sz = .2 TO 35 STEP .2
  219.                 CIRCLE (player.x + check, player.y - check), sz, _RGB32(127, 127, 127)
  220.             NEXT sz
  221.             GOSUB findgold:
  222.         END IF
  223.         IF POINT(player.x - check, player.y + check) = _RGB32(255, 255, 128) THEN
  224.             _DEST map
  225.             FOR sz = .2 TO 35 STEP .2
  226.                 CIRCLE (player.x - check, player.y + check), sz, _RGB32(127, 127, 127)
  227.             NEXT sz
  228.             GOSUB findgold:
  229.         END IF
  230.     NEXT check
  231.     _DISPLAY
  232.     _LIMIT 60
  233.  
  234. findgold:
  235. FOR snd = 800 TO 400 STEP -100
  236.     SOUND snd, .5
  237. NEXT snd
  238. score = score + 100
  239. score$ = STR$(score)
  240. level$ = STR$(level)
  241. _TITLE "Level: " + level$ + "   Score: " + score$
  242. IF score / 2000 = INT(score / 2000) THEN
  243.     level = level + 1
  244.     level$ = STR$(level)
  245.     _TITLE "Level: " + level$ + "   Score: " + score$
  246.     IF level = 21 THEN GOTO win:
  247.     GOTO start2:
  248.  
  249. done:
  250. LOCATE 10, 55: PRINT "G A M E     O V E R"
  251. FOR snd = 450 TO 150 STEP -25
  252.     SOUND snd, .5
  253. NEXT snd
  254. LOCATE 13, 55: PRINT "Again (Y/N)?"
  255. ag:
  256. ag$ = INKEY$
  257. IF ag$ = "y" OR ag$ = "Y" THEN GOTO start:
  258. IF ag$ = "n" OR ag$ = "N" THEN END
  259. GOTO ag:
  260.  
  261. win:
  262. LOCATE 10, 55: PRINT "G A M E     W O N ! ! ! ! ! ! !"
  263. FOR snd = 450 TO 150 STEP -25
  264.     SOUND snd, .5
  265. NEXT snd
  266. LOCATE 13, 55: PRINT "Again (Y/N)?"
  267. ag2:
  268. ag$ = INKEY$
  269. IF ag$ = "y" OR ag$ = "Y" THEN GOTO start:
  270. IF ag$ = "n" OR ag$ = "N" THEN END
  271. GOTO ag2:
  272.  
  273. 'Thanks to FelippeHeitor for this Sub and the camera code above.
  274. SUB adjustCamera
  275.     IF player.x + camera.x > _WIDTH / 2 OR player.x + camera.x < _WIDTH / 2 THEN
  276.         camera.x = _WIDTH / 2 - player.x
  277.     END IF
  278.     IF camera.x > 0 THEN camera.x = 0
  279.     IF camera.x < -(_WIDTH(map) - _WIDTH) THEN camera.x = -(_WIDTH(map) - _WIDTH)
  280.  
  281.     IF player.y + camera.y > _HEIGHT / 2 OR player.y + camera.y < _HEIGHT / 2 THEN
  282.         camera.y = _HEIGHT / 2 - player.y
  283.     END IF
  284.     IF camera.y > 0 THEN camera.y = 0
  285.     IF camera.y < -(_HEIGHT(map) - _HEIGHT) THEN camera.y = -(_HEIGHT(map) - _HEIGHT)
  286.  
Title: Re: Find The Gold!
Post by: johnno56 on October 24, 2020, 04:16:37 am
I could be wrong....

Replacing line #33 with 'LINE (0, 0)-STEP(_WIDTH * 7, _HEIGHT * 7), _RGB32(0, 200, 0), BF' maybe a longer command but I think it maybe a quicker method of "filling" the screen and perhaps a little more efficient on memory...

Just a thought...

J
Title: Re: Find The Gold!
Post by: qbkiller101 on October 24, 2020, 05:24:54 am
@SierraKen now I have to change my code too :c
anyways, here's the code I made before this post was made:
Code: QB64: [Select]
  1. 'Find the Gold! by SierraKen
  2. 'October 21, 2020
  3. 'Thanks for the great mapping code by FellipeHeitor and help from B+!
  4. 'This is mostly an example game, I hope to expand on it sometime soon.
  5. 'October 22, 2020
  6. 'Edits by Omer H., or qbkiller101 in the forums
  7. 'Added wasd support, fast and normal mode (see 113), and choosing
  8. 'dimensions for people with small screens (like me)
  9.  
  10.  
  11. SCREEN _NEWIMAGE(500, 400, 256)
  12. LINE (125, 100)-(375, 175), 15, BF
  13. LINE (125, 225)-(375, 300), 15, BF
  14. _PRINTSTRING (150, 0), "Choose the dimensions:"
  15. _PRINTSTRING (210, 125), "800 x 600"
  16. _PRINTSTRING (175, 250), "Default (1000 x 800)"
  17. dimx% = 800
  18. dimy% = 600
  19. ischosen = false
  20. WHILE ischosen = false
  21.         IF _MOUSEX > 125 AND _MOUSEX < 375 THEN
  22.             IF _MOUSEY > 100 AND _MOUSEY < 175 THEN
  23.                 IF _MOUSEBUTTON(1) = -1 THEN
  24.                     dimx% = 800
  25.                     dimy% = 600
  26.                     ischosen = true
  27.                     EXIT WHILE
  28.                 END IF
  29.             END IF
  30.         END IF
  31.         IF _MOUSEX > 125 AND _MOUSEX < 375 THEN
  32.             IF _MOUSEY > 225 AND _MOUSEY < 300 THEN
  33.                 IF _MOUSEBUTTON(1) = -1 THEN
  34.                     dimx% = 1000
  35.                     dimy% = 800
  36.                     ischosen = true
  37.                     EXIT WHILE
  38.                 END IF
  39.             END IF
  40.         END IF
  41.  
  42.     LOOP
  43. SCREEN _NEWIMAGE(dimx%, dimy%, 32)
  44. TYPE object
  45.     x AS SINGLE
  46.     y AS SINGLE
  47.  
  48. DIM SHARED player AS object
  49. DIM SHARED camera AS object
  50. DIM playerSpeed AS SINGLE
  51. DIM score AS INTEGER
  52. CONST height800 = 4200
  53. CONST width800 = 5600
  54. CONST height1000 = 5600
  55. CONST width1000 = 7000
  56.  
  57. _TITLE "Find The Gold! One gold bar per map. Use your arrow and wasd keys."
  58.  
  59. start:
  60. player.x = _WIDTH / 2
  61. player.y = _HEIGHT / 2
  62.  
  63. map = _NEWIMAGE(_WIDTH * 7, _HEIGHT * 7, 32)
  64.  
  65. _DEST map
  66. PAINT (2, 2), _RGB32(0, 200, 0)
  67.  
  68. IF _WIDTH = width800 AND _HEIGHT = height800 THEN
  69.  
  70.  
  71. w2 = INT(RND * _WIDTH) - 15
  72. h2 = INT(RND * _HEIGHT) - 10
  73. IF w2 < 15 THEN w2 = 15
  74. IF h2 < 10 THEN h2 = 10
  75.  
  76. 'Gold
  77. COLOR _RGB32(0, 0, 0), _RGB32(255, 255, 128)
  78. _PRINTSTRING (w2, h2), "GOLD"
  79.  
  80.  
  81.  
  82. playerSpeed = 10
  83.  
  84. CONST keyUP = 18432
  85. CONST keyDOWN = 20480
  86. CONST keyLEFT = 19200
  87. CONST keyRIGHT = 19712
  88.  
  89.     CLS
  90.  
  91.     _PUTIMAGE (camera.x, camera.y), map
  92.  
  93.     IF _KEYDOWN(keyUP) THEN player.y = player.y - playerSpeed
  94.     IF _KEYDOWN(keyDOWN) THEN player.y = player.y + playerSpeed
  95.     IF _KEYDOWN(keyLEFT) THEN player.x = player.x - playerSpeed
  96.     IF _KEYDOWN(keyRIGHT) THEN player.x = player.x + playerSpeed
  97.     IF _KEYDOWN(119) THEN player.y = player.y - playerSpeed 'Omer Hijazi
  98.     IF _KEYDOWN(115) THEN player.y = player.y + playerSpeed 'Omer Hijazi
  99.     IF _KEYDOWN(97) THEN player.x = player.x - playerSpeed 'Omer Hijazi
  100.     IF _KEYDOWN(100) THEN player.x = player.x + playerSpeed 'Omer Hijazi
  101.  
  102.  
  103.     IF player.x < 0 THEN player.x = 0
  104.     IF player.x > _WIDTH(map) THEN player.x = _WIDTH(map)
  105.     IF player.y < 0 THEN player.y = 0
  106.     IF player.y > _HEIGHT(map) THEN player.y = _HEIGHT(map)
  107.  
  108.     adjustCamera
  109.  
  110.     'Draw Head
  111.     FOR sz = .25 TO 10 STEP .25
  112.         CIRCLE (player.x + camera.x, player.y + camera.y), sz, _RGB32(255, 166, 127)
  113.     NEXT sz
  114.     'Draw Smile
  115.     CIRCLE (player.x + camera.x, player.y + camera.y + 2), 7, _RGB32(255, 0, 0), _PI, 2 * _PI, .5
  116.     'Draw Eyes
  117.     CIRCLE (player.x + camera.x - 4, player.y + camera.y - 2), 1, _RGB32(0, 0, 255)
  118.     CIRCLE (player.x + camera.x + 4, player.y + camera.y - 2), 1, _RGB32(0, 0, 255)
  119.     'hat
  120.     LINE (player.x + camera.x - 10, player.y + camera.y - 10)-(player.x + camera.x + 10, player.y + camera.y - 9), _RGB32(155, 0, 0), BF
  121.     LINE (player.x + camera.x - 5, player.y + camera.y - 9)-(player.x + camera.x + 5, player.y + camera.y - 15), _RGB32(155, 0, 0), BF
  122.     FOR check = -15 TO 15
  123.         IF POINT(player.x + check, player.y + check) = _RGB32(255, 255, 128) THEN SOUND 500, .5: score = score + 100: score$ = STR$(score): _TITLE "Score: " + score$: GOTO start:
  124.         IF POINT(player.x + check, player.y - check) = _RGB32(255, 255, 128) THEN SOUND 500, .5: score = score + 100: score$ = STR$(score): _TITLE "Score: " + score$: GOTO start:
  125.         IF POINT(player.x - check, player.y + check) = _RGB32(255, 255, 128) THEN SOUND 500, .5: score = score + 100: score$ = STR$(score): _TITLE "Score: " + score$: GOTO start:
  126.     NEXT check
  127.  
  128.     _DISPLAY
  129.     _LIMIT 60
  130.  
  131. SUB adjustCamera
  132.     IF player.x + camera.x > _WIDTH / 2 OR player.x + camera.x < _WIDTH / 2 THEN
  133.         camera.x = _WIDTH / 2 - player.x
  134.     END IF
  135.     IF camera.x > 0 THEN camera.x = 0
  136.     IF camera.x < -(_WIDTH(map) - _WIDTH) THEN camera.x = -(_WIDTH(map) - _WIDTH)
  137.  
  138.     IF player.y + camera.y > _HEIGHT / 2 OR player.y + camera.y < _HEIGHT / 2 THEN
  139.         camera.y = _HEIGHT / 2 - player.y
  140.     END IF
  141.     IF camera.y > 0 THEN camera.y = 0
  142.     IF camera.y < -(_HEIGHT(map) - _HEIGHT) THEN camera.y = -(_HEIGHT(map) - _HEIGHT)
and also, you should make a git repo for collaboration
Title: Re: Find The Gold!
Post by: FellippeHeitor on October 24, 2020, 09:19:29 am
I could be wrong....

Replacing line #33 with 'LINE (0, 0)-STEP(_WIDTH * 7, _HEIGHT * 7), _RGB32(0, 200, 0), BF' maybe a longer command but I think it maybe a quicker method of "filling" the screen and perhaps a little more efficient on memory...

Just a thought...

J

Might wanna try this too:

Code: QB64: [Select]
  1. CLS ,  _RGB32(0, 200, 0)
Title: Re: Find The Gold!
Post by: Aurel on October 24, 2020, 09:30:46 am
very good, maybe better will be with more natural objects but then will be lot more larger ?
all in all ..nice ;
Title: Re: Find The Gold!
Post by: SierraKen on October 24, 2020, 02:44:32 pm
Thanks everyone! Using the CLS , _RGB32(0,200,0) makes a huge improvement on loading time! Thanks to all of you for the suggestions.

On this version I have made many improvements, here's the list:

Changed PAINT to CLS , _RGB32(0,200,0) which greatly improves the loading speed.
Added 4 times the amount of trees and made 3 levels of mountains.
Added random creeks. Added twice the lakes with random shapes.
Changed screen size to 800 x 600 to be compatible with all players.
Added 100 seconds to level time, to 400 for level 1.
Slowed player speed from 10 to 8.
Changed color after you get the gold from brown to green.
Changed to a happier sound when getting gold.

Code: QB64: [Select]
  1. 'Find the Gold! by SierraKen
  2. 'October 24, 2020
  3. 'Thanks for the great mapping code by FellipeHeitor and help from B+!
  4. 'Additions:
  5. 'Body, Arms, and Legs. Levels and 20 gold per level. Larger land area sizes. Lakes and Trees. 20 Level limit.
  6. 'Changed PAINT to CLS , _RGB32(0,200,0) which greatly improves the loading speed.
  7. 'Added 4 times the amount of trees and made 3 levels of mountains.
  8. 'Added random creeks. Added twice the lakes with random shapes.
  9. 'Changed screen size to 800 x 600 to be compatible with all players.
  10. 'Added 100 seconds to level time, to 400 for level 1.
  11. 'Slowed player speed from 10 to 8.
  12. 'Changed color after you get the gold from brown to green.
  13. 'Changed to a happier sound when getting gold.
  14.  
  15. SCREEN _NEWIMAGE(800, 600, 32)
  16.  
  17. TYPE object
  18.     x AS SINGLE
  19.     y AS SINGLE
  20.  
  21. DIM SHARED player AS object
  22. DIM SHARED camera AS object
  23. DIM playerSpeed AS SINGLE
  24.  
  25. _TITLE "Find The Gold!"
  26.  
  27. start:
  28. score = 0
  29. level = 1
  30.  
  31. start2:
  32. player.x = _WIDTH / 2
  33. player.y = _HEIGHT / 2
  34.  
  35. map = _NEWIMAGE(_WIDTH * 7, _HEIGHT * 7, 32)
  36.  
  37. _DEST map
  38. CLS , _RGB32(0, 200, 0)
  39.  
  40. 'Land Areas
  41. FOR blocks = 1 TO 400
  42.     blocks:
  43.     xx = (RND * _WIDTH)
  44.     yy = (RND * _HEIGHT)
  45.     sz = INT(RND * 300) + 50
  46.     blockcolors:
  47.     c1 = INT(RND * 155) + 100
  48.     c2 = INT(RND * 155) + 100
  49.     c3 = INT(RND * 155) + 100
  50.     IF c1 = 255 AND c2 = 255 AND c3 = 128 THEN GOTO blockcolors:
  51.     c4 = INT(RND * 155) + 100
  52.     c5 = INT(RND * 155) + 100
  53.     c6 = INT(RND * 155) + 100
  54.     blockcolors2:
  55.     IF c4 = 255 AND c5 = 255 AND c6 = 128 THEN GOTO blockcolors2:
  56.     c7 = INT(RND * 155) + 100
  57.     c8 = INT(RND * 155) + 100
  58.     c9 = INT(RND * 155) + 100
  59.     blockcolors3:
  60.     IF c7 = 255 AND c8 = 255 AND c9 = 128 THEN GOTO blockcolors3:
  61.  
  62.     LINE (xx, yy)-(xx + sz, yy + sz), _RGB32(c1, c2, c3), BF
  63.     LINE (xx + (sz * .25), yy + (sz * .25))-(xx + (sz * .75), yy + (sz * .75)), _RGB32(c4, c5, c6), BF
  64.     LINE (xx + (sz * .40), yy + (sz * .40))-(xx + (sz * .60), yy + (sz * .60)), _RGB32(c7, c8, c9), BF
  65.  
  66.  
  67. 'Lakes
  68. FOR lakes = 1 TO 20
  69.     w = RND
  70.     h = RND
  71.     sze = (RND * 200) + 50
  72.     shape = RND
  73.     FOR sz = .25 TO sze STEP .25
  74.         CIRCLE (w * _WIDTH, h * _HEIGHT), sz, _RGB32(0, 128, 255), , , shape
  75.     NEXT sz
  76. NEXT lakes
  77.  
  78. 'Creeks
  79. FOR creeks = 1 TO 100
  80.     cw1 = RND * _WIDTH
  81.     ch1 = RND * _HEIGHT
  82.     cw2 = (RND * 50) + cw1
  83.     ch2 = (RND * 50) + ch1
  84.     cw3 = (RND * 50) + cw2
  85.     ch3 = (RND * 50) + ch2
  86.     cw4 = (RND * 50) + cw3
  87.     ch4 = (RND * 50) + ch3
  88.     cw5 = (RND * 50) + cw4
  89.     ch5 = (RND * 50) + ch4
  90.     cw6 = (RND * 50) + cw5
  91.     ch6 = (RND * 50) + ch5
  92.     cw7 = (RND * 50) + cw6
  93.     ch7 = (RND * 50) + ch6
  94.     cw8 = (RND * 50) + cw7
  95.     ch8 = (RND * 50) + ch7
  96.     cw9 = (RND * 50) + cw8
  97.     ch9 = (RND * 50) + ch8
  98.     cw10 = (RND * 50) + cw9
  99.     ch10 = (RND * 50) + ch9
  100.  
  101.     LINE (cw1, ch1)-(cw2, ch2), _RGB32(0, 128, 255)
  102.     LINE (cw2, ch2)-(cw3, ch3), _RGB32(0, 128, 255)
  103.     LINE (cw3, ch3)-(cw4, ch4), _RGB32(0, 128, 255)
  104.     LINE (cw4, ch4)-(cw5, ch5), _RGB32(0, 128, 255)
  105.     LINE (cw5, ch5)-(cw6, ch6), _RGB32(0, 128, 255)
  106.     LINE (cw6, ch6)-(cw7, ch7), _RGB32(0, 128, 255)
  107.     LINE (cw7, ch7)-(cw8, ch8), _RGB32(0, 128, 255)
  108.     LINE (cw8, ch8)-(cw9, ch9), _RGB32(0, 128, 255)
  109.     LINE (cw9, ch9)-(cw10, ch10), _RGB32(0, 128, 255)
  110.  
  111. NEXT creeks
  112.  
  113. 'Trees
  114. FOR trees = 1 TO 1600
  115.     tx = RND
  116.     tx = tx * _WIDTH
  117.     ty = RND
  118.     ty = ty * _HEIGHT
  119.     tsz = (RND * 40) + 10
  120.     LINE (tx, ty)-(tx, ty + tsz + 5), _RGB32(188, 127, 127)
  121.     FOR branches = ty TO ty + tsz STEP 3
  122.         LINE (tx, branches)-(tx - 10, branches + 5), _RGB32(127, 255, 127)
  123.         LINE (tx, branches)-(tx + 10, branches + 5), _RGB32(127, 255, 127)
  124.     NEXT branches
  125. NEXT trees
  126.  
  127. 'Place Gold
  128. FOR gold = 1 TO 20
  129.     gold:
  130.     w2 = INT(RND * _WIDTH) - 40
  131.     h2 = INT(RND * _HEIGHT) - 40
  132.     IF w2 < 40 THEN w2 = 40
  133.     IF h2 < 40 THEN h2 = 40
  134.     IF POINT(w2, h2) = _RGB32(255, 255, 128) THEN GOTO gold:
  135.     IF POINT(w2, h2) = _RGB32(0, 0, 0) THEN GOTO gold:
  136.     'Gold
  137.     COLOR _RGB32(0, 0, 0), _RGB32(255, 255, 128)
  138.     _PRINTSTRING (w2, h2), "GOLD"
  139. NEXT gold
  140.  
  141.  
  142.  
  143. playerSpeed = 8
  144.  
  145. CONST keyUP = 18432
  146. CONST keyDOWN = 20480
  147. CONST keyLEFT = 19200
  148. CONST keyRIGHT = 19712
  149. CONST keyESC = 27
  150. _PUTIMAGE (camera.x, camera.y), map
  151.  
  152. LOCATE 3, 30: PRINT "Use the arrow keys to find 20 gold bars per level."
  153. LOCATE 4, 30: PRINT "Every level will have a shorter time."
  154. LOCATE 5, 30: PRINT "After Level 20 you win the game."
  155. LOCATE 10, 40: PRINT "Press Any Key To Begin."
  156.  
  157. pause:
  158. a$ = INKEY$
  159. IF a$ <> "" THEN GOTO begin:
  160. GOTO pause:
  161.  
  162. begin:
  163.  
  164. seconds = INT(TIMER)
  165.     CLS
  166.     leveltime = level * 5
  167.     gametime = (405 - leveltime) - (INT(TIMER) - seconds)
  168.     _PUTIMAGE (camera.x, camera.y), map
  169.     LOCATE 1, 1: PRINT "Time Left: "; gametime
  170.     IF gametime < 1 THEN GOTO done:
  171.     IF _KEYDOWN(keyUP) THEN
  172.         player.y = player.y - playerSpeed
  173.         t = t + 1
  174.     END IF
  175.     IF _KEYDOWN(keyDOWN) THEN
  176.         player.y = player.y + playerSpeed
  177.         t = t + 1
  178.     END IF
  179.     IF _KEYDOWN(keyLEFT) THEN
  180.         player.x = player.x - playerSpeed
  181.         t = t + 1
  182.     END IF
  183.     IF _KEYDOWN(keyRIGHT) THEN
  184.         player.x = player.x + playerSpeed
  185.         t = t + 1
  186.     END IF
  187.     IF _KEYDOWN(keyESC) THEN END
  188.     IF player.x < 0 THEN player.x = 0
  189.     IF player.x > _WIDTH(map) THEN player.x = _WIDTH(map)
  190.     IF player.y < 0 THEN player.y = 0
  191.     IF player.y > _HEIGHT(map) THEN player.y = _HEIGHT(map)
  192.  
  193.     adjustCamera
  194.  
  195.     'Draw Head
  196.     FOR sz = .25 TO 10 STEP .25
  197.         CIRCLE (player.x + camera.x, player.y + camera.y), sz, _RGB32(255, 166, 127)
  198.     NEXT sz
  199.     'Draw Smile
  200.     CIRCLE (player.x + camera.x, player.y + camera.y + 2), 7, _RGB32(255, 0, 0), _PI, 2 * _PI, .5
  201.     'Draw Eyes
  202.     CIRCLE (player.x + camera.x - 4, player.y + camera.y - 2), 1, _RGB32(0, 0, 255)
  203.     CIRCLE (player.x + camera.x + 4, player.y + camera.y - 2), 1, _RGB32(0, 0, 255)
  204.     'hat
  205.     LINE (player.x + camera.x - 10, player.y + camera.y - 10)-(player.x + camera.x + 10, player.y + camera.y - 9), _RGB32(155, 0, 0), BF
  206.     LINE (player.x + camera.x - 5, player.y + camera.y - 9)-(player.x + camera.x + 5, player.y + camera.y - 15), _RGB32(155, 0, 0), BF
  207.     'body
  208.     LINE (player.x + camera.x, player.y + camera.y + 10)-(player.x + camera.x, player.y + camera.y + 20), _RGB32(155, 0, 0)
  209.  
  210.     IF t > 7 THEN t = 0
  211.  
  212.     'rest of body
  213.     IF t = 0 THEN
  214.         'left arm
  215.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 15, player.y + camera.y + 25), _RGB32(155, 0, 0)
  216.         'right arm
  217.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 15, player.y + camera.y + 25), _RGB32(155, 0, 0)
  218.         'left leg
  219.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 15, player.y + camera.y + 35), _RGB32(155, 0, 0)
  220.         'right leg
  221.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 15, player.y + camera.y + 35), _RGB32(155, 0, 0)
  222.     END IF
  223.  
  224.     IF t = 1 OR t = 7 THEN
  225.         'left arm
  226.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 11, player.y + camera.y + 25), _RGB32(155, 0, 0)
  227.         'right arm
  228.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 11, player.y + camera.y + 25), _RGB32(155, 0, 0)
  229.         'left leg
  230.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 11, player.y + camera.y + 35), _RGB32(155, 0, 0)
  231.         'right leg
  232.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 11, player.y + camera.y + 35), _RGB32(155, 0, 0)
  233.     END IF
  234.  
  235.     IF t = 2 OR t = 6 THEN
  236.         'left arm
  237.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 9, player.y + camera.y + 24), _RGB32(155, 0, 0)
  238.         'right arm
  239.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 9, player.y + camera.y + 24), _RGB32(155, 0, 0)
  240.         'left leg
  241.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 9, player.y + camera.y + 35), _RGB32(155, 0, 0)
  242.         'right leg
  243.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 9, player.y + camera.y + 35), _RGB32(155, 0, 0)
  244.     END IF
  245.  
  246.     IF t = 3 OR t = 5 THEN
  247.         'left arm
  248.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 7, player.y + camera.y + 24), _RGB32(155, 0, 0)
  249.         'right arm
  250.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 7, player.y + camera.y + 24), _RGB32(155, 0, 0)
  251.         'left leg
  252.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 7, player.y + camera.y + 35), _RGB32(155, 0, 0)
  253.         'right leg
  254.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 7, player.y + camera.y + 35), _RGB32(155, 0, 0)
  255.     END IF
  256.  
  257.     IF t = 4 THEN
  258.         'left arm
  259.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 5, player.y + camera.y + 23), _RGB32(155, 0, 0)
  260.         'right arm
  261.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 5, player.y + camera.y + 23), _RGB32(155, 0, 0)
  262.         'left leg
  263.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 5, player.y + camera.y + 35), _RGB32(155, 0, 0)
  264.         'right leg
  265.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 5, player.y + camera.y + 35), _RGB32(155, 0, 0)
  266.     END IF
  267.  
  268.     FOR check = -15 TO 15
  269.         IF POINT(player.x + check, player.y + check) = _RGB32(255, 255, 128) THEN
  270.             _DEST map
  271.             FOR sz = .2 TO 35 STEP .2
  272.                 CIRCLE (player.x + check, player.y + check), sz, _RGB32(127, 255, 127)
  273.             NEXT sz
  274.             GOSUB findgold:
  275.         END IF
  276.         IF POINT(player.x + check, player.y - check) = _RGB32(255, 255, 128) THEN
  277.             _DEST map
  278.             FOR sz = .2 TO 35 STEP .2
  279.                 CIRCLE (player.x + check, player.y - check), sz, _RGB32(127, 255, 127)
  280.             NEXT sz
  281.             GOSUB findgold:
  282.         END IF
  283.         IF POINT(player.x - check, player.y + check) = _RGB32(255, 255, 128) THEN
  284.             _DEST map
  285.             FOR sz = .2 TO 35 STEP .2
  286.                 CIRCLE (player.x - check, player.y + check), sz, _RGB32(127, 255, 127)
  287.             NEXT sz
  288.             GOSUB findgold:
  289.         END IF
  290.     NEXT check
  291.     _DISPLAY
  292.     _LIMIT 60
  293.  
  294. findgold:
  295. FOR snd = 400 TO 800 STEP 100
  296.     SOUND snd, .5
  297. NEXT snd
  298. score = score + 100
  299. score$ = STR$(score)
  300. level$ = STR$(level)
  301. _TITLE "Level: " + level$ + "   Score: " + score$
  302. IF score / 2000 = INT(score / 2000) THEN
  303.     level = level + 1
  304.     level$ = STR$(level)
  305.     _TITLE "Level: " + level$ + "   Score: " + score$
  306.     IF level = 21 THEN GOTO win:
  307.     GOTO start2:
  308.  
  309. done:
  310. LOCATE 10, 55: PRINT "G A M E     O V E R"
  311. FOR snd = 450 TO 150 STEP -25
  312.     SOUND snd, .5
  313. NEXT snd
  314. LOCATE 13, 55: PRINT "Again (Y/N)?"
  315. ag:
  316. ag$ = INKEY$
  317. IF ag$ = "y" OR ag$ = "Y" THEN GOTO start:
  318. IF ag$ = "n" OR ag$ = "N" THEN END
  319. GOTO ag:
  320.  
  321. win:
  322. LOCATE 10, 55: PRINT "G A M E     W O N ! ! ! ! ! ! !"
  323. FOR snd = 450 TO 150 STEP -25
  324.     SOUND snd, .5
  325. NEXT snd
  326. LOCATE 13, 55: PRINT "Again (Y/N)?"
  327. ag2:
  328. ag$ = INKEY$
  329. IF ag$ = "y" OR ag$ = "Y" THEN GOTO start:
  330. IF ag$ = "n" OR ag$ = "N" THEN END
  331. GOTO ag2:
  332.  
  333. 'Thanks to FelippeHeitor for this Sub and the camera code above.
  334. SUB adjustCamera
  335.     IF player.x + camera.x > _WIDTH / 2 OR player.x + camera.x < _WIDTH / 2 THEN
  336.         camera.x = _WIDTH / 2 - player.x
  337.     END IF
  338.     IF camera.x > 0 THEN camera.x = 0
  339.     IF camera.x < -(_WIDTH(map) - _WIDTH) THEN camera.x = -(_WIDTH(map) - _WIDTH)
  340.     IF player.y + camera.y > _HEIGHT / 2 OR player.y + camera.y < _HEIGHT / 2 THEN
  341.         camera.y = _HEIGHT / 2 - player.y
  342.     END IF
  343.     IF camera.y > 0 THEN camera.y = 0
  344.     IF camera.y < -(_HEIGHT(map) - _HEIGHT) THEN camera.y = -(_HEIGHT(map) - _HEIGHT)
  345.  
Title: Re: Find The Gold!
Post by: SierraKen on October 24, 2020, 02:56:40 pm
Here is another quick update for WASD player movement support (along with arrow keys). I remember B+ didn't like the arrow keys and I see QBKiller needs this as well. Thanks QBKiller for the keydown numbers. :) I also included a picture of the game below.

Code: QB64: [Select]
  1. 'Find the Gold! by SierraKen
  2. 'October 24, 2020
  3. 'Thanks for the great mapping code by FellipeHeitor and help from B+!
  4. 'Additions:
  5. 'Body, Arms, and Legs. Levels and 20 gold per level. Larger land area sizes. Lakes and Trees. 20 Level limit.
  6. 'Changed PAINT to CLS , _RGB32(0,200,0) which greatly improves the loading speed.
  7. 'Added 4 times the amount of trees and made 3 levels of mountains.
  8. 'Added random creeks. Added twice the lakes with random shapes.
  9. 'Changed screen size to 800 x 600 to be compatible with all players.
  10. 'Added 100 seconds to level time, to 400 for level 1.
  11. 'Slowed player speed from 10 to 8.
  12. 'Changed to a happier sound when getting gold.
  13. 'Changed color after you get the gold from brown to green.
  14. 'Added WASD keys to move player along with arrow keys.
  15.  
  16. SCREEN _NEWIMAGE(800, 600, 32)
  17.  
  18. TYPE object
  19.     x AS SINGLE
  20.     y AS SINGLE
  21.  
  22. DIM SHARED player AS object
  23. DIM SHARED camera AS object
  24. DIM playerSpeed AS SINGLE
  25.  
  26. _TITLE "Find The Gold!"
  27.  
  28. start:
  29. score = 0
  30. level = 1
  31.  
  32. start2:
  33. player.x = _WIDTH / 2
  34. player.y = _HEIGHT / 2
  35.  
  36. map = _NEWIMAGE(_WIDTH * 7, _HEIGHT * 7, 32)
  37.  
  38. _DEST map
  39. CLS , _RGB32(0, 200, 0)
  40.  
  41. 'Land Areas
  42. FOR blocks = 1 TO 400
  43.     blocks:
  44.     xx = (RND * _WIDTH)
  45.     yy = (RND * _HEIGHT)
  46.     sz = INT(RND * 300) + 50
  47.     blockcolors:
  48.     c1 = INT(RND * 155) + 100
  49.     c2 = INT(RND * 155) + 100
  50.     c3 = INT(RND * 155) + 100
  51.     IF c1 = 255 AND c2 = 255 AND c3 = 128 THEN GOTO blockcolors:
  52.     c4 = INT(RND * 155) + 100
  53.     c5 = INT(RND * 155) + 100
  54.     c6 = INT(RND * 155) + 100
  55.     blockcolors2:
  56.     IF c4 = 255 AND c5 = 255 AND c6 = 128 THEN GOTO blockcolors2:
  57.     c7 = INT(RND * 155) + 100
  58.     c8 = INT(RND * 155) + 100
  59.     c9 = INT(RND * 155) + 100
  60.     blockcolors3:
  61.     IF c7 = 255 AND c8 = 255 AND c9 = 128 THEN GOTO blockcolors3:
  62.  
  63.     LINE (xx, yy)-(xx + sz, yy + sz), _RGB32(c1, c2, c3), BF
  64.     LINE (xx + (sz * .25), yy + (sz * .25))-(xx + (sz * .75), yy + (sz * .75)), _RGB32(c4, c5, c6), BF
  65.     LINE (xx + (sz * .40), yy + (sz * .40))-(xx + (sz * .60), yy + (sz * .60)), _RGB32(c7, c8, c9), BF
  66.  
  67.  
  68. 'Lakes
  69. FOR lakes = 1 TO 20
  70.     w = RND
  71.     h = RND
  72.     sze = (RND * 200) + 50
  73.     shape = RND
  74.     FOR sz = .25 TO sze STEP .25
  75.         CIRCLE (w * _WIDTH, h * _HEIGHT), sz, _RGB32(0, 128, 255), , , shape
  76.     NEXT sz
  77. NEXT lakes
  78.  
  79. 'Creeks
  80. FOR creeks = 1 TO 100
  81.     cw1 = RND * _WIDTH
  82.     ch1 = RND * _HEIGHT
  83.     cw2 = (RND * 50) + cw1
  84.     ch2 = (RND * 50) + ch1
  85.     cw3 = (RND * 50) + cw2
  86.     ch3 = (RND * 50) + ch2
  87.     cw4 = (RND * 50) + cw3
  88.     ch4 = (RND * 50) + ch3
  89.     cw5 = (RND * 50) + cw4
  90.     ch5 = (RND * 50) + ch4
  91.     cw6 = (RND * 50) + cw5
  92.     ch6 = (RND * 50) + ch5
  93.     cw7 = (RND * 50) + cw6
  94.     ch7 = (RND * 50) + ch6
  95.     cw8 = (RND * 50) + cw7
  96.     ch8 = (RND * 50) + ch7
  97.     cw9 = (RND * 50) + cw8
  98.     ch9 = (RND * 50) + ch8
  99.     cw10 = (RND * 50) + cw9
  100.     ch10 = (RND * 50) + ch9
  101.  
  102.     LINE (cw1, ch1)-(cw2, ch2), _RGB32(0, 128, 255)
  103.     LINE (cw2, ch2)-(cw3, ch3), _RGB32(0, 128, 255)
  104.     LINE (cw3, ch3)-(cw4, ch4), _RGB32(0, 128, 255)
  105.     LINE (cw4, ch4)-(cw5, ch5), _RGB32(0, 128, 255)
  106.     LINE (cw5, ch5)-(cw6, ch6), _RGB32(0, 128, 255)
  107.     LINE (cw6, ch6)-(cw7, ch7), _RGB32(0, 128, 255)
  108.     LINE (cw7, ch7)-(cw8, ch8), _RGB32(0, 128, 255)
  109.     LINE (cw8, ch8)-(cw9, ch9), _RGB32(0, 128, 255)
  110.     LINE (cw9, ch9)-(cw10, ch10), _RGB32(0, 128, 255)
  111.  
  112. NEXT creeks
  113.  
  114. 'Trees
  115. FOR trees = 1 TO 1600
  116.     tx = RND
  117.     tx = tx * _WIDTH
  118.     ty = RND
  119.     ty = ty * _HEIGHT
  120.     tsz = (RND * 40) + 10
  121.     LINE (tx, ty)-(tx, ty + tsz + 5), _RGB32(188, 127, 127)
  122.     FOR branches = ty TO ty + tsz STEP 3
  123.         LINE (tx, branches)-(tx - 10, branches + 5), _RGB32(127, 255, 127)
  124.         LINE (tx, branches)-(tx + 10, branches + 5), _RGB32(127, 255, 127)
  125.     NEXT branches
  126. NEXT trees
  127.  
  128. 'Place Gold
  129. FOR gold = 1 TO 20
  130.     gold:
  131.     w2 = INT(RND * _WIDTH) - 40
  132.     h2 = INT(RND * _HEIGHT) - 40
  133.     IF w2 < 40 THEN w2 = 40
  134.     IF h2 < 40 THEN h2 = 40
  135.     IF POINT(w2, h2) = _RGB32(255, 255, 128) THEN GOTO gold:
  136.     IF POINT(w2, h2) = _RGB32(0, 0, 0) THEN GOTO gold:
  137.     'Gold
  138.     COLOR _RGB32(0, 0, 0), _RGB32(255, 255, 128)
  139.     _PRINTSTRING (w2, h2), "GOLD"
  140. NEXT gold
  141.  
  142.  
  143.  
  144. playerSpeed = 8
  145.  
  146. CONST keyUP = 18432
  147. CONST keyDOWN = 20480
  148. CONST keyLEFT = 19200
  149. CONST keyRIGHT = 19712
  150. CONST keyESC = 27
  151. _PUTIMAGE (camera.x, camera.y), map
  152.  
  153. LOCATE 3, 30: PRINT "Use the arrow keys (or WASD keys) to find 20 gold bars per level."
  154. LOCATE 4, 30: PRINT "Every level will have a shorter time."
  155. LOCATE 5, 30: PRINT "After Level 20 you win the game."
  156. LOCATE 10, 40: PRINT "Press Any Key To Begin."
  157.  
  158. pause:
  159. a$ = INKEY$
  160. IF a$ <> "" THEN GOTO begin:
  161. GOTO pause:
  162.  
  163. begin:
  164.  
  165. seconds = INT(TIMER)
  166.     CLS
  167.     leveltime = level * 5
  168.     gametime = (405 - leveltime) - (INT(TIMER) - seconds)
  169.     _PUTIMAGE (camera.x, camera.y), map
  170.     LOCATE 1, 1: PRINT "Time Left: "; gametime
  171.     IF gametime < 1 THEN GOTO done:
  172.     IF _KEYDOWN(keyUP) OR _KEYDOWN(119) THEN
  173.         player.y = player.y - playerSpeed
  174.         t = t + 1
  175.     END IF
  176.     IF _KEYDOWN(keyDOWN) OR _KEYDOWN(115) THEN
  177.         player.y = player.y + playerSpeed
  178.         t = t + 1
  179.     END IF
  180.     IF _KEYDOWN(keyLEFT) OR _KEYDOWN(97) THEN
  181.         player.x = player.x - playerSpeed
  182.         t = t + 1
  183.     END IF
  184.     IF _KEYDOWN(keyRIGHT) OR _KEYDOWN(100) THEN
  185.         player.x = player.x + playerSpeed
  186.         t = t + 1
  187.     END IF
  188.     IF _KEYDOWN(keyESC) THEN END
  189.     IF player.x < 0 THEN player.x = 0
  190.     IF player.x > _WIDTH(map) THEN player.x = _WIDTH(map)
  191.     IF player.y < 0 THEN player.y = 0
  192.     IF player.y > _HEIGHT(map) THEN player.y = _HEIGHT(map)
  193.  
  194.     adjustCamera
  195.  
  196.     'Draw Head
  197.     FOR sz = .25 TO 10 STEP .25
  198.         CIRCLE (player.x + camera.x, player.y + camera.y), sz, _RGB32(255, 166, 127)
  199.     NEXT sz
  200.     'Draw Smile
  201.     CIRCLE (player.x + camera.x, player.y + camera.y + 2), 7, _RGB32(255, 0, 0), _PI, 2 * _PI, .5
  202.     'Draw Eyes
  203.     CIRCLE (player.x + camera.x - 4, player.y + camera.y - 2), 1, _RGB32(0, 0, 255)
  204.     CIRCLE (player.x + camera.x + 4, player.y + camera.y - 2), 1, _RGB32(0, 0, 255)
  205.     'hat
  206.     LINE (player.x + camera.x - 10, player.y + camera.y - 10)-(player.x + camera.x + 10, player.y + camera.y - 9), _RGB32(155, 0, 0), BF
  207.     LINE (player.x + camera.x - 5, player.y + camera.y - 9)-(player.x + camera.x + 5, player.y + camera.y - 15), _RGB32(155, 0, 0), BF
  208.     'body
  209.     LINE (player.x + camera.x, player.y + camera.y + 10)-(player.x + camera.x, player.y + camera.y + 20), _RGB32(155, 0, 0)
  210.  
  211.     IF t > 7 THEN t = 0
  212.  
  213.     'rest of body
  214.     IF t = 0 THEN
  215.         'left arm
  216.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 15, player.y + camera.y + 25), _RGB32(155, 0, 0)
  217.         'right arm
  218.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 15, player.y + camera.y + 25), _RGB32(155, 0, 0)
  219.         'left leg
  220.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 15, player.y + camera.y + 35), _RGB32(155, 0, 0)
  221.         'right leg
  222.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 15, player.y + camera.y + 35), _RGB32(155, 0, 0)
  223.     END IF
  224.  
  225.     IF t = 1 OR t = 7 THEN
  226.         'left arm
  227.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 11, player.y + camera.y + 25), _RGB32(155, 0, 0)
  228.         'right arm
  229.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 11, player.y + camera.y + 25), _RGB32(155, 0, 0)
  230.         'left leg
  231.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 11, player.y + camera.y + 35), _RGB32(155, 0, 0)
  232.         'right leg
  233.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 11, player.y + camera.y + 35), _RGB32(155, 0, 0)
  234.     END IF
  235.  
  236.     IF t = 2 OR t = 6 THEN
  237.         'left arm
  238.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 9, player.y + camera.y + 24), _RGB32(155, 0, 0)
  239.         'right arm
  240.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 9, player.y + camera.y + 24), _RGB32(155, 0, 0)
  241.         'left leg
  242.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 9, player.y + camera.y + 35), _RGB32(155, 0, 0)
  243.         'right leg
  244.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 9, player.y + camera.y + 35), _RGB32(155, 0, 0)
  245.     END IF
  246.  
  247.     IF t = 3 OR t = 5 THEN
  248.         'left arm
  249.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 7, player.y + camera.y + 24), _RGB32(155, 0, 0)
  250.         'right arm
  251.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 7, player.y + camera.y + 24), _RGB32(155, 0, 0)
  252.         'left leg
  253.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 7, player.y + camera.y + 35), _RGB32(155, 0, 0)
  254.         'right leg
  255.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 7, player.y + camera.y + 35), _RGB32(155, 0, 0)
  256.     END IF
  257.  
  258.     IF t = 4 THEN
  259.         'left arm
  260.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 5, player.y + camera.y + 23), _RGB32(155, 0, 0)
  261.         'right arm
  262.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 5, player.y + camera.y + 23), _RGB32(155, 0, 0)
  263.         'left leg
  264.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 5, player.y + camera.y + 35), _RGB32(155, 0, 0)
  265.         'right leg
  266.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 5, player.y + camera.y + 35), _RGB32(155, 0, 0)
  267.     END IF
  268.  
  269.  
  270.     FOR check = -15 TO 15
  271.         IF POINT(player.x + check, player.y + check) = _RGB32(255, 255, 128) THEN
  272.             _DEST map
  273.             FOR sz = .2 TO 35 STEP .2
  274.                 CIRCLE (player.x + check, player.y + check), sz, _RGB32(127, 255, 127)
  275.             NEXT sz
  276.             GOSUB findgold:
  277.         END IF
  278.         IF POINT(player.x + check, player.y - check) = _RGB32(255, 255, 128) THEN
  279.             _DEST map
  280.             FOR sz = .2 TO 35 STEP .2
  281.                 CIRCLE (player.x + check, player.y - check), sz, _RGB32(127, 255, 127)
  282.             NEXT sz
  283.             GOSUB findgold:
  284.         END IF
  285.         IF POINT(player.x - check, player.y + check) = _RGB32(255, 255, 128) THEN
  286.             _DEST map
  287.             FOR sz = .2 TO 35 STEP .2
  288.                 CIRCLE (player.x - check, player.y + check), sz, _RGB32(127, 255, 127)
  289.             NEXT sz
  290.             GOSUB findgold:
  291.         END IF
  292.     NEXT check
  293.     _DISPLAY
  294.     _LIMIT 60
  295.  
  296. findgold:
  297. FOR snd = 400 TO 800 STEP 100
  298.     SOUND snd, .5
  299. NEXT snd
  300. score = score + 100
  301. score$ = STR$(score)
  302. level$ = STR$(level)
  303. _TITLE "Level: " + level$ + "   Score: " + score$
  304. IF score / 2000 = INT(score / 2000) THEN
  305.     level = level + 1
  306.     level$ = STR$(level)
  307.     _TITLE "Level: " + level$ + "   Score: " + score$
  308.     IF level = 21 THEN GOTO win:
  309.     GOTO start2:
  310.  
  311. done:
  312. LOCATE 10, 55: PRINT "G A M E     O V E R"
  313. FOR snd = 450 TO 150 STEP -25
  314.     SOUND snd, .5
  315. NEXT snd
  316. LOCATE 13, 55: PRINT "Again (Y/N)?"
  317. ag:
  318. ag$ = INKEY$
  319. IF ag$ = "y" OR ag$ = "Y" THEN GOTO start:
  320. IF ag$ = "n" OR ag$ = "N" THEN END
  321. GOTO ag:
  322.  
  323. win:
  324. LOCATE 10, 55: PRINT "G A M E     W O N ! ! ! ! ! ! !"
  325. FOR snd = 450 TO 150 STEP -25
  326.     SOUND snd, .5
  327. NEXT snd
  328. LOCATE 13, 55: PRINT "Again (Y/N)?"
  329. ag2:
  330. ag$ = INKEY$
  331. IF ag$ = "y" OR ag$ = "Y" THEN GOTO start:
  332. IF ag$ = "n" OR ag$ = "N" THEN END
  333. GOTO ag2:
  334.  
  335. 'Thanks to FelippeHeitor for this Sub and the camera code above.
  336. SUB adjustCamera
  337.     IF player.x + camera.x > _WIDTH / 2 OR player.x + camera.x < _WIDTH / 2 THEN
  338.         camera.x = _WIDTH / 2 - player.x
  339.     END IF
  340.     IF camera.x > 0 THEN camera.x = 0
  341.     IF camera.x < -(_WIDTH(map) - _WIDTH) THEN camera.x = -(_WIDTH(map) - _WIDTH)
  342.  
  343.     IF player.y + camera.y > _HEIGHT / 2 OR player.y + camera.y < _HEIGHT / 2 THEN
  344.         camera.y = _HEIGHT / 2 - player.y
  345.     END IF
  346.     IF camera.y > 0 THEN camera.y = 0
  347.     IF camera.y < -(_HEIGHT(map) - _HEIGHT) THEN camera.y = -(_HEIGHT(map) - _HEIGHT)
  348.  
Title: Re: Find The Gold!
Post by: SierraKen on October 24, 2020, 06:29:34 pm
I just removed the Atari looking square mountains and put more realistic looking hills in its place. I also put the lakes on the ground (before everything else is placed). It took me awhile to figure out how to overlap the hills correctly. So instead of a random vertical coordinate for them, I just use yy=yy+4 and made the horizontal value random. Check out the picture below. :) I'm super happy about this. Oh also, since it still takes a couple seconds to load with all of the hill graphics, I added a "Loading...." in the Topic bar so people know to wait.
Also, just so you all know, I will be gone from Sunday afternoon to Wednesday because my power company is shutting off 1000's of people's power in Northern California for their Public Safety Power Shut-Offs they do when dry winds come. I'll be back later this week. But please check out this version. I really think I'm getting better at my games thanks to all of you!
On a side note: This game does get a bit boring if you keep playing it. I suggest playing it for a couple of levels and that's about it. I'll probably add bad guys or something to make more action and harder to play. But the main reason I like it is because it gets you thinking about running around in the mountains. :)

Code: QB64: [Select]
  1. 'Find the Gold! by SierraKen
  2. 'October 24, 2020
  3. 'Thanks for the great mapping code by FellipeHeitor and help from B+!
  4. 'Additions:
  5. 'Body, Arms, and Legs. Levels and 20 gold per level. Larger land area sizes. Lakes and Trees. 20 Level limit.
  6. 'Changed PAINT to CLS , _RGB32(0,200,0) which greatly improves the loading speed.
  7. 'Added 4 times the amount of trees and made 3 levels of mountains.
  8. 'Added random creeks. Added twice the lakes with random shapes.
  9. 'Changed screen size to 800 x 600 to be compatible with all players.
  10. 'Added 100 seconds to level time, to 400 for level 1.
  11. 'Slowed player speed from 10 to 8.
  12. 'Changed to a happier sound when getting gold.
  13. 'Changed color after you get the gold from brown to green.
  14. 'Added WASD keys to move player along with arrow keys.
  15. 'Removed the square mountains and made more realistic hills.
  16. 'Put the lakes on the ground, before everything else.
  17. 'Added Loading.... in the topic bar.
  18.  
  19. SCREEN _NEWIMAGE(800, 600, 32)
  20.  
  21. TYPE object
  22.     x AS SINGLE
  23.     y AS SINGLE
  24.  
  25. DIM SHARED player AS object
  26. DIM SHARED camera AS object
  27. DIM playerSpeed AS SINGLE
  28.  
  29. _TITLE "Loading....."
  30.  
  31. start:
  32. score = 0
  33. level = 1
  34.  
  35. start2:
  36. player.x = _WIDTH / 2
  37. player.y = _HEIGHT / 2
  38.  
  39. map = _NEWIMAGE(_WIDTH * 7, _HEIGHT * 7, 32)
  40.  
  41. _DEST map
  42.  
  43. CLS , _RGB32(0, 200, 0)
  44.  
  45. 'Lakes
  46. FOR lakes = 1 TO 100
  47.     w = RND
  48.     h = RND
  49.     sze = (RND * 250) + 100
  50.     shape = RND
  51.     FOR sz = .25 TO sze STEP .25
  52.         CIRCLE (w * _WIDTH, h * _HEIGHT), sz, _RGB32(0, 128, 255), , , shape
  53.     NEXT sz
  54. NEXT lakes
  55.  
  56.  
  57. 'Hills
  58. FOR hills = 1 TO 1200
  59.     _LIMIT 2000
  60.     xx = (RND * _WIDTH)
  61.     sz = INT(RND * 100) + 200
  62.     shape = RND
  63.     hillcolors:
  64.     c1 = INT(RND * 100) + 55
  65.     c2 = INT(RND * 100) + 55
  66.     c3 = INT(RND * 100) + 55
  67.     IF c1 = 255 AND c2 = 255 AND c3 = 128 THEN GOTO hillcolors:
  68.     yy = yy + 4
  69.     FOR hill = 1 TO sz STEP .25
  70.         hh = hh + .025
  71.         IF hh > 100 THEN hh = 100
  72.         cc1 = c1 + hh
  73.         cc2 = c2 + hh
  74.         cc3 = c3 + hh
  75.         CIRCLE (xx, yy), hill, _RGB32(cc1, cc2, cc3), 2 * _PI, _PI, shape
  76.     NEXT hill
  77.     hh = 0
  78. NEXT hills
  79. yy = 0
  80.  
  81. 'Creeks
  82. FOR creeks = 1 TO 100
  83.     cw1 = RND * _WIDTH
  84.     ch1 = RND * _HEIGHT
  85.     cw2 = (RND * 50) + cw1
  86.     ch2 = (RND * 50) + ch1
  87.     cw3 = (RND * 50) + cw2
  88.     ch3 = (RND * 50) + ch2
  89.     cw4 = (RND * 50) + cw3
  90.     ch4 = (RND * 50) + ch3
  91.     cw5 = (RND * 50) + cw4
  92.     ch5 = (RND * 50) + ch4
  93.     cw6 = (RND * 50) + cw5
  94.     ch6 = (RND * 50) + ch5
  95.     cw7 = (RND * 50) + cw6
  96.     ch7 = (RND * 50) + ch6
  97.     cw8 = (RND * 50) + cw7
  98.     ch8 = (RND * 50) + ch7
  99.     cw9 = (RND * 50) + cw8
  100.     ch9 = (RND * 50) + ch8
  101.     cw10 = (RND * 50) + cw9
  102.     ch10 = (RND * 50) + ch9
  103.  
  104.     LINE (cw1, ch1)-(cw2, ch2), _RGB32(0, 128, 255)
  105.     LINE (cw2, ch2)-(cw3, ch3), _RGB32(0, 128, 255)
  106.     LINE (cw3, ch3)-(cw4, ch4), _RGB32(0, 128, 255)
  107.     LINE (cw4, ch4)-(cw5, ch5), _RGB32(0, 128, 255)
  108.     LINE (cw5, ch5)-(cw6, ch6), _RGB32(0, 128, 255)
  109.     LINE (cw6, ch6)-(cw7, ch7), _RGB32(0, 128, 255)
  110.     LINE (cw7, ch7)-(cw8, ch8), _RGB32(0, 128, 255)
  111.     LINE (cw8, ch8)-(cw9, ch9), _RGB32(0, 128, 255)
  112.     LINE (cw9, ch9)-(cw10, ch10), _RGB32(0, 128, 255)
  113.  
  114. NEXT creeks
  115.  
  116. 'Trees
  117. FOR trees = 1 TO 1600
  118.     tx = RND
  119.     tx = tx * _WIDTH
  120.     ty = RND
  121.     ty = ty * _HEIGHT
  122.     tsz = (RND * 40) + 10
  123.     LINE (tx, ty)-(tx, ty + tsz + 5), _RGB32(188, 127, 127)
  124.     FOR branches = ty TO ty + tsz STEP 3
  125.         LINE (tx, branches)-(tx - 10, branches + 5), _RGB32(127, 255, 127)
  126.         LINE (tx, branches)-(tx + 10, branches + 5), _RGB32(127, 255, 127)
  127.     NEXT branches
  128. NEXT trees
  129.  
  130. 'Place Gold
  131. FOR gold = 1 TO 20
  132.     gold:
  133.     w2 = INT(RND * _WIDTH) - 40
  134.     h2 = INT(RND * _HEIGHT) - 40
  135.     IF w2 < 40 THEN w2 = 40
  136.     IF h2 < 40 THEN h2 = 40
  137.     IF POINT(w2, h2) = _RGB32(255, 255, 128) THEN GOTO gold:
  138.     IF POINT(w2, h2) = _RGB32(0, 0, 0) THEN GOTO gold:
  139.     'Gold
  140.     COLOR _RGB32(0, 0, 0), _RGB32(255, 255, 128)
  141.     _PRINTSTRING (w2, h2), "GOLD"
  142. NEXT gold
  143.  
  144.  
  145. _TITLE "Find The Gold!"
  146. playerSpeed = 8
  147.  
  148. CONST keyUP = 18432
  149. CONST keyDOWN = 20480
  150. CONST keyLEFT = 19200
  151. CONST keyRIGHT = 19712
  152. CONST keyESC = 27
  153. _PUTIMAGE (camera.x, camera.y), map
  154.  
  155. LOCATE 3, 30: PRINT "Use the arrow keys (or WASD keys) to find 20 gold bars per level."
  156. LOCATE 4, 30: PRINT "Every level will have a shorter time."
  157. LOCATE 5, 30: PRINT "After Level 20 you win the game."
  158. LOCATE 10, 40: PRINT "Press Any Key To Begin."
  159.  
  160. pause:
  161. a$ = INKEY$
  162. IF a$ <> "" THEN GOTO begin:
  163. GOTO pause:
  164.  
  165. begin:
  166.  
  167. seconds = INT(TIMER)
  168.     CLS
  169.     leveltime = level * 5
  170.     gametime = (405 - leveltime) - (INT(TIMER) - seconds)
  171.     _PUTIMAGE (camera.x, camera.y), map
  172.     LOCATE 1, 1: PRINT "Time Left: "; gametime
  173.     IF gametime < 1 THEN GOTO done:
  174.     IF _KEYDOWN(keyUP) OR _KEYDOWN(119) THEN
  175.         player.y = player.y - playerSpeed
  176.         t = t + 1
  177.     END IF
  178.     IF _KEYDOWN(keyDOWN) OR _KEYDOWN(115) THEN
  179.         player.y = player.y + playerSpeed
  180.         t = t + 1
  181.     END IF
  182.     IF _KEYDOWN(keyLEFT) OR _KEYDOWN(97) THEN
  183.         player.x = player.x - playerSpeed
  184.         t = t + 1
  185.     END IF
  186.     IF _KEYDOWN(keyRIGHT) OR _KEYDOWN(100) THEN
  187.         player.x = player.x + playerSpeed
  188.         t = t + 1
  189.     END IF
  190.     IF _KEYDOWN(keyESC) THEN END
  191.     IF player.x < 0 THEN player.x = 0
  192.     IF player.x > _WIDTH(map) THEN player.x = _WIDTH(map)
  193.     IF player.y < 0 THEN player.y = 0
  194.     IF player.y > _HEIGHT(map) THEN player.y = _HEIGHT(map)
  195.  
  196.     adjustCamera
  197.  
  198.     'Draw Head
  199.     FOR sz = .25 TO 10 STEP .25
  200.         CIRCLE (player.x + camera.x, player.y + camera.y), sz, _RGB32(255, 166, 127)
  201.     NEXT sz
  202.     'Draw Smile
  203.     CIRCLE (player.x + camera.x, player.y + camera.y + 2), 7, _RGB32(255, 0, 0), _PI, 2 * _PI, .5
  204.     'Draw Eyes
  205.     CIRCLE (player.x + camera.x - 4, player.y + camera.y - 2), 1, _RGB32(0, 0, 255)
  206.     CIRCLE (player.x + camera.x + 4, player.y + camera.y - 2), 1, _RGB32(0, 0, 255)
  207.     'hat
  208.     LINE (player.x + camera.x - 10, player.y + camera.y - 10)-(player.x + camera.x + 10, player.y + camera.y - 9), _RGB32(155, 0, 0), BF
  209.     LINE (player.x + camera.x - 5, player.y + camera.y - 9)-(player.x + camera.x + 5, player.y + camera.y - 15), _RGB32(155, 0, 0), BF
  210.     'body
  211.     LINE (player.x + camera.x, player.y + camera.y + 10)-(player.x + camera.x, player.y + camera.y + 20), _RGB32(155, 0, 0)
  212.  
  213.     IF t > 7 THEN t = 0
  214.  
  215.     'rest of body
  216.     IF t = 0 THEN
  217.         'left arm
  218.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 15, player.y + camera.y + 25), _RGB32(155, 0, 0)
  219.         'right arm
  220.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 15, player.y + camera.y + 25), _RGB32(155, 0, 0)
  221.         'left leg
  222.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 15, player.y + camera.y + 35), _RGB32(155, 0, 0)
  223.         'right leg
  224.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 15, player.y + camera.y + 35), _RGB32(155, 0, 0)
  225.     END IF
  226.  
  227.     IF t = 1 OR t = 7 THEN
  228.         'left arm
  229.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 11, player.y + camera.y + 25), _RGB32(155, 0, 0)
  230.         'right arm
  231.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 11, player.y + camera.y + 25), _RGB32(155, 0, 0)
  232.         'left leg
  233.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 11, player.y + camera.y + 35), _RGB32(155, 0, 0)
  234.         'right leg
  235.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 11, player.y + camera.y + 35), _RGB32(155, 0, 0)
  236.     END IF
  237.  
  238.     IF t = 2 OR t = 6 THEN
  239.         'left arm
  240.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 9, player.y + camera.y + 24), _RGB32(155, 0, 0)
  241.         'right arm
  242.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 9, player.y + camera.y + 24), _RGB32(155, 0, 0)
  243.         'left leg
  244.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 9, player.y + camera.y + 35), _RGB32(155, 0, 0)
  245.         'right leg
  246.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 9, player.y + camera.y + 35), _RGB32(155, 0, 0)
  247.     END IF
  248.  
  249.     IF t = 3 OR t = 5 THEN
  250.         'left arm
  251.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 7, player.y + camera.y + 24), _RGB32(155, 0, 0)
  252.         'right arm
  253.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 7, player.y + camera.y + 24), _RGB32(155, 0, 0)
  254.         'left leg
  255.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 7, player.y + camera.y + 35), _RGB32(155, 0, 0)
  256.         'right leg
  257.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 7, player.y + camera.y + 35), _RGB32(155, 0, 0)
  258.     END IF
  259.  
  260.     IF t = 4 THEN
  261.         'left arm
  262.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 5, player.y + camera.y + 23), _RGB32(155, 0, 0)
  263.         'right arm
  264.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 5, player.y + camera.y + 23), _RGB32(155, 0, 0)
  265.         'left leg
  266.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 5, player.y + camera.y + 35), _RGB32(155, 0, 0)
  267.         'right leg
  268.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 5, player.y + camera.y + 35), _RGB32(155, 0, 0)
  269.     END IF
  270.  
  271.  
  272.     FOR check = -15 TO 15
  273.         IF POINT(player.x + check, player.y + check) = _RGB32(255, 255, 128) THEN
  274.             _DEST map
  275.             FOR sz = .2 TO 35 STEP .2
  276.                 CIRCLE (player.x + check, player.y + check), sz, _RGB32(127, 255, 127)
  277.             NEXT sz
  278.             GOSUB findgold:
  279.         END IF
  280.         IF POINT(player.x + check, player.y - check) = _RGB32(255, 255, 128) THEN
  281.             _DEST map
  282.             FOR sz = .2 TO 35 STEP .2
  283.                 CIRCLE (player.x + check, player.y - check), sz, _RGB32(127, 255, 127)
  284.             NEXT sz
  285.             GOSUB findgold:
  286.         END IF
  287.         IF POINT(player.x - check, player.y + check) = _RGB32(255, 255, 128) THEN
  288.             _DEST map
  289.             FOR sz = .2 TO 35 STEP .2
  290.                 CIRCLE (player.x - check, player.y + check), sz, _RGB32(127, 255, 127)
  291.             NEXT sz
  292.             GOSUB findgold:
  293.         END IF
  294.     NEXT check
  295.     _DISPLAY
  296.     _LIMIT 60
  297.  
  298. findgold:
  299. FOR snd = 400 TO 800 STEP 100
  300.     SOUND snd, .5
  301. NEXT snd
  302. score = score + 100
  303. score$ = STR$(score)
  304. level$ = STR$(level)
  305. _TITLE "Level: " + level$ + "   Score: " + score$
  306. IF score / 2000 = INT(score / 2000) THEN
  307.     level = level + 1
  308.     level$ = STR$(level)
  309.     _TITLE "Level: " + level$ + "   Score: " + score$
  310.     IF level = 21 THEN GOTO win:
  311.     GOTO start2:
  312.  
  313. done:
  314. LOCATE 10, 55: PRINT "G A M E     O V E R"
  315. FOR snd = 450 TO 150 STEP -25
  316.     SOUND snd, .5
  317. NEXT snd
  318. LOCATE 13, 55: PRINT "Again (Y/N)?"
  319. ag:
  320. ag$ = INKEY$
  321. IF ag$ = "y" OR ag$ = "Y" THEN GOTO start:
  322. IF ag$ = "n" OR ag$ = "N" THEN END
  323. GOTO ag:
  324.  
  325. win:
  326. LOCATE 10, 55: PRINT "G A M E     W O N ! ! ! ! ! ! !"
  327. FOR snd = 450 TO 150 STEP -25
  328.     SOUND snd, .5
  329. NEXT snd
  330. LOCATE 13, 55: PRINT "Again (Y/N)?"
  331. ag2:
  332. ag$ = INKEY$
  333. IF ag$ = "y" OR ag$ = "Y" THEN GOTO start:
  334. IF ag$ = "n" OR ag$ = "N" THEN END
  335. GOTO ag2:
  336.  
  337. 'Thanks to FelippeHeitor for this Sub and the camera code above.
  338. SUB adjustCamera
  339.     IF player.x + camera.x > _WIDTH / 2 OR player.x + camera.x < _WIDTH / 2 THEN
  340.         camera.x = _WIDTH / 2 - player.x
  341.     END IF
  342.     IF camera.x > 0 THEN camera.x = 0
  343.     IF camera.x < -(_WIDTH(map) - _WIDTH) THEN camera.x = -(_WIDTH(map) - _WIDTH)
  344.  
  345.     IF player.y + camera.y > _HEIGHT / 2 OR player.y + camera.y < _HEIGHT / 2 THEN
  346.         camera.y = _HEIGHT / 2 - player.y
  347.     END IF
  348.     IF camera.y > 0 THEN camera.y = 0
  349.     IF camera.y < -(_HEIGHT(map) - _HEIGHT) THEN camera.y = -(_HEIGHT(map) - _HEIGHT)
  350.  
Title: Re: Find The Gold!
Post by: bplus on October 25, 2020, 11:26:21 am
Well I definitely like your 2nd version of mountains and lake! Now if we can get the trees dark green to brown and wider at base than top... ;-))

Is it cherry picked or have you managed not to get trees in the lake? ;)
Ohp! no there's a tree in the lake, oh well ;-))

Oh and should lose the rivers coming down from sky!
Title: Re: Find The Gold!
Post by: SierraKen on October 25, 2020, 11:44:00 am
Thanks B+! Well the rivers aren't actually in the sky, they are 2 different rivers on different hills. Because there is no sky in my game but I understand what you mean. Just pretend they are 2 different rivers. :) Good idea on the trees, I'll see what I can do. I don't have much time today so if I don't post anything, I'll try to post when my power comes back on around Wed. from the Public Safety Power Shut-Off.
Title: Re: Find The Gold!
Post by: bplus on October 25, 2020, 12:03:03 pm
Man that sucks about the power! Don't need another Colorado and California has enough fires already.

The overhead view of map is probably better for game just saying landscape looked better.
Title: Re: Find The Gold!
Post by: bplus on October 25, 2020, 12:14:57 pm
This might be a little off topic but does anyone have code for drawing isobars around say 3 or 4 hill or mountain peaks?

That would look good for overhead map and gold would be found around streams from mountains.
Title: Re: Find The Gold!
Post by: SierraKen on October 25, 2020, 12:29:40 pm
I got the trees really good now. :) I also decided to remove the creeks because after a few attempts, I couldn't figure out how to keep a creek on its own hill. It looks much cleaner without the creeks anyway. I also made a little less trees to ease up on memory.

Note: Don't use this one, the title bar is messed up. The fix is on the next forum page.

Code: QB64: [Select]
  1. 'Find the Gold! by SierraKen
  2. 'October 24, 2020
  3. 'Thanks for the great mapping code by FellipeHeitor and help from B+!
  4. 'Additions:
  5. 'Body, Arms, and Legs. Levels and 20 gold per level. Larger land area sizes. Lakes and Trees. 20 Level limit.
  6. 'Changed PAINT to CLS , _RGB32(0,200,0) which greatly improves the loading speed.
  7. 'Added 4 times the amount of trees and made 3 levels of mountains.
  8. 'Added random creeks. Added twice the lakes with random shapes.
  9. 'Changed screen size to 800 x 600 to be compatible with all players.
  10. 'Added 100 seconds to level time, to 400 for level 1.
  11. 'Slowed player speed from 10 to 8.
  12. 'Changed to a happier sound when getting gold.
  13. 'Changed color after you get the gold from brown to green.
  14. 'Added WASD keys to move player along with arrow keys.
  15. 'Removed the square mountains and made more realistic hills.
  16. 'Put the lakes on the ground, before everything else.
  17. 'Made trees look better.
  18. 'Removed creeks.
  19.  
  20. SCREEN _NEWIMAGE(800, 600, 32)
  21.  
  22. TYPE object
  23.     x AS SINGLE
  24.     y AS SINGLE
  25.  
  26. DIM SHARED player AS object
  27. DIM SHARED camera AS object
  28. DIM playerSpeed AS SINGLE
  29.  
  30. _TITLE "Loading....."
  31.  
  32. start:
  33. score = 0
  34. level = 1
  35.  
  36. start2:
  37. player.x = _WIDTH / 2
  38. player.y = _HEIGHT / 2
  39.  
  40. map = _NEWIMAGE(_WIDTH * 7, _HEIGHT * 7, 32)
  41.  
  42. _DEST map
  43.  
  44. CLS , _RGB32(0, 200, 0)
  45. _LIMIT 2000
  46.  
  47. 'Lakes
  48. FOR lakes = 1 TO 100
  49.     w = RND
  50.     h = RND
  51.     sze = (RND * 250) + 100
  52.     shape = RND
  53.     FOR sz = .25 TO sze STEP .25
  54.         CIRCLE (w * _WIDTH, h * _HEIGHT), sz, _RGB32(0, 128, 255), , , shape
  55.     NEXT sz
  56. NEXT lakes
  57.  
  58.  
  59. 'Hills
  60. FOR hills = 1 TO 1200
  61.     xx = (RND * _WIDTH)
  62.     sz = INT(RND * 100) + 200
  63.     shape = RND
  64.     hillcolors:
  65.     c1 = INT(RND * 100) + 55
  66.     c2 = INT(RND * 100) + 55
  67.     c3 = INT(RND * 100) + 55
  68.     IF c1 = 255 AND c2 = 255 AND c3 = 128 THEN GOTO hillcolors:
  69.     yy = yy + 4
  70.     FOR hill = 1 TO sz STEP .25
  71.         hh = hh + .025
  72.         IF hh > 100 THEN hh = 100
  73.         cc1 = c1 + hh
  74.         cc2 = c2 + hh
  75.         cc3 = c3 + hh
  76.         CIRCLE (xx, yy), hill, _RGB32(cc1, cc2, cc3), 2 * _PI, _PI, shape
  77.     NEXT hill
  78.     hh = 0
  79. NEXT hills
  80. yy = 0
  81.  
  82.  
  83. 'Trees
  84. FOR trees = 1 TO 1000
  85.     tx = RND
  86.     tx = tx * _WIDTH
  87.     ty = RND
  88.     ty = ty * _HEIGHT
  89.     tsz = (RND * 40) + 10
  90.     LINE (tx, ty)-(tx, ty + tsz + 5), _RGB32(188, 127, 127)
  91.     FOR branches = ty TO ty + tsz STEP 3
  92.         trim = trim + 2
  93.         LINE (tx, branches)-(tx - trim, branches + 5), _RGB32(0, 183, 127)
  94.         LINE (tx, branches)-(tx + trim, branches + 5), _RGB32(0, 183, 127)
  95.     NEXT branches
  96.     trim = 0
  97. NEXT trees
  98.  
  99. 'Place Gold
  100. FOR gold = 1 TO 20
  101.     gold:
  102.     w2 = INT(RND * _WIDTH) - 40
  103.     h2 = INT(RND * _HEIGHT) - 40
  104.     IF w2 < 40 THEN w2 = 40
  105.     IF h2 < 40 THEN h2 = 40
  106.     IF POINT(w2, h2) = _RGB32(255, 255, 128) THEN GOTO gold:
  107.     IF POINT(w2, h2) = _RGB32(0, 0, 0) THEN GOTO gold:
  108.     'Gold
  109.     COLOR _RGB32(0, 0, 0), _RGB32(255, 255, 128)
  110.     _PRINTSTRING (w2, h2), "GOLD"
  111. NEXT gold
  112.  
  113.  
  114.  
  115. playerSpeed = 8
  116.  
  117. CONST keyUP = 18432
  118. CONST keyDOWN = 20480
  119. CONST keyLEFT = 19200
  120. CONST keyRIGHT = 19712
  121. CONST keyESC = 27
  122. _PUTIMAGE (camera.x, camera.y), map
  123.  
  124. LOCATE 3, 30: PRINT "Use the arrow keys (or WASD keys) to find 20 gold bars per level."
  125. LOCATE 4, 30: PRINT "Every level will have a shorter time."
  126. LOCATE 5, 30: PRINT "After Level 20 you win the game."
  127. LOCATE 10, 40: PRINT "Press Any Key To Begin."
  128.  
  129. pause:
  130. a$ = INKEY$
  131. IF a$ <> "" THEN GOTO begin:
  132. GOTO pause:
  133.  
  134. begin:
  135.  
  136. seconds = INT(TIMER)
  137.     CLS
  138.     leveltime = level * 5
  139.     gametime = (405 - leveltime) - (INT(TIMER) - seconds)
  140.     _PUTIMAGE (camera.x, camera.y), map
  141.     LOCATE 1, 1: PRINT "Time Left: "; gametime
  142.     IF gametime < 1 THEN GOTO done:
  143.     IF _KEYDOWN(keyUP) OR _KEYDOWN(119) THEN
  144.         player.y = player.y - playerSpeed
  145.         t = t + 1
  146.     END IF
  147.     IF _KEYDOWN(keyDOWN) OR _KEYDOWN(115) THEN
  148.         player.y = player.y + playerSpeed
  149.         t = t + 1
  150.     END IF
  151.     IF _KEYDOWN(keyLEFT) OR _KEYDOWN(97) THEN
  152.         player.x = player.x - playerSpeed
  153.         t = t + 1
  154.     END IF
  155.     IF _KEYDOWN(keyRIGHT) OR _KEYDOWN(100) THEN
  156.         player.x = player.x + playerSpeed
  157.         t = t + 1
  158.     END IF
  159.     IF _KEYDOWN(keyESC) THEN END
  160.     IF player.x < 0 THEN player.x = 0
  161.     IF player.x > _WIDTH(map) THEN player.x = _WIDTH(map)
  162.     IF player.y < 0 THEN player.y = 0
  163.     IF player.y > _HEIGHT(map) THEN player.y = _HEIGHT(map)
  164.  
  165.     adjustCamera
  166.  
  167.     'Draw Head
  168.     FOR sz = .25 TO 10 STEP .25
  169.         CIRCLE (player.x + camera.x, player.y + camera.y), sz, _RGB32(255, 166, 127)
  170.     NEXT sz
  171.     'Draw Smile
  172.     CIRCLE (player.x + camera.x, player.y + camera.y + 2), 7, _RGB32(255, 0, 0), _PI, 2 * _PI, .5
  173.     'Draw Eyes
  174.     CIRCLE (player.x + camera.x - 4, player.y + camera.y - 2), 1, _RGB32(0, 0, 255)
  175.     CIRCLE (player.x + camera.x + 4, player.y + camera.y - 2), 1, _RGB32(0, 0, 255)
  176.     'hat
  177.     LINE (player.x + camera.x - 10, player.y + camera.y - 10)-(player.x + camera.x + 10, player.y + camera.y - 9), _RGB32(155, 0, 0), BF
  178.     LINE (player.x + camera.x - 5, player.y + camera.y - 9)-(player.x + camera.x + 5, player.y + camera.y - 15), _RGB32(155, 0, 0), BF
  179.     'body
  180.     LINE (player.x + camera.x, player.y + camera.y + 10)-(player.x + camera.x, player.y + camera.y + 20), _RGB32(155, 0, 0)
  181.  
  182.     IF t > 7 THEN t = 0
  183.  
  184.     'rest of body
  185.     IF t = 0 THEN
  186.         'left arm
  187.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 15, player.y + camera.y + 25), _RGB32(155, 0, 0)
  188.         'right arm
  189.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 15, player.y + camera.y + 25), _RGB32(155, 0, 0)
  190.         'left leg
  191.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 15, player.y + camera.y + 35), _RGB32(155, 0, 0)
  192.         'right leg
  193.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 15, player.y + camera.y + 35), _RGB32(155, 0, 0)
  194.     END IF
  195.  
  196.     IF t = 1 OR t = 7 THEN
  197.         'left arm
  198.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 11, player.y + camera.y + 25), _RGB32(155, 0, 0)
  199.         'right arm
  200.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 11, player.y + camera.y + 25), _RGB32(155, 0, 0)
  201.         'left leg
  202.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 11, player.y + camera.y + 35), _RGB32(155, 0, 0)
  203.         'right leg
  204.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 11, player.y + camera.y + 35), _RGB32(155, 0, 0)
  205.     END IF
  206.  
  207.     IF t = 2 OR t = 6 THEN
  208.         'left arm
  209.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 9, player.y + camera.y + 24), _RGB32(155, 0, 0)
  210.         'right arm
  211.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 9, player.y + camera.y + 24), _RGB32(155, 0, 0)
  212.         'left leg
  213.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 9, player.y + camera.y + 35), _RGB32(155, 0, 0)
  214.         'right leg
  215.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 9, player.y + camera.y + 35), _RGB32(155, 0, 0)
  216.     END IF
  217.  
  218.     IF t = 3 OR t = 5 THEN
  219.         'left arm
  220.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 7, player.y + camera.y + 24), _RGB32(155, 0, 0)
  221.         'right arm
  222.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 7, player.y + camera.y + 24), _RGB32(155, 0, 0)
  223.         'left leg
  224.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 7, player.y + camera.y + 35), _RGB32(155, 0, 0)
  225.         'right leg
  226.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 7, player.y + camera.y + 35), _RGB32(155, 0, 0)
  227.     END IF
  228.  
  229.     IF t = 4 THEN
  230.         'left arm
  231.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 5, player.y + camera.y + 23), _RGB32(155, 0, 0)
  232.         'right arm
  233.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 5, player.y + camera.y + 23), _RGB32(155, 0, 0)
  234.         'left leg
  235.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 5, player.y + camera.y + 35), _RGB32(155, 0, 0)
  236.         'right leg
  237.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 5, player.y + camera.y + 35), _RGB32(155, 0, 0)
  238.     END IF
  239.  
  240.  
  241.     FOR check = -15 TO 15
  242.         IF POINT(player.x + check, player.y + check) = _RGB32(255, 255, 128) THEN
  243.             _DEST map
  244.             FOR sz = .2 TO 35 STEP .2
  245.                 CIRCLE (player.x + check, player.y + check), sz, _RGB32(127, 255, 127)
  246.             NEXT sz
  247.             GOSUB findgold:
  248.         END IF
  249.         IF POINT(player.x + check, player.y - check) = _RGB32(255, 255, 128) THEN
  250.             _DEST map
  251.             FOR sz = .2 TO 35 STEP .2
  252.                 CIRCLE (player.x + check, player.y - check), sz, _RGB32(127, 255, 127)
  253.             NEXT sz
  254.             GOSUB findgold:
  255.         END IF
  256.         IF POINT(player.x - check, player.y + check) = _RGB32(255, 255, 128) THEN
  257.             _DEST map
  258.             FOR sz = .2 TO 35 STEP .2
  259.                 CIRCLE (player.x - check, player.y + check), sz, _RGB32(127, 255, 127)
  260.             NEXT sz
  261.             GOSUB findgold:
  262.         END IF
  263.     NEXT check
  264.     _DISPLAY
  265.     _LIMIT 60
  266.  
  267. findgold:
  268. FOR snd = 400 TO 800 STEP 100
  269.     SOUND snd, .5
  270. NEXT snd
  271. score = score + 100
  272. score$ = STR$(score)
  273. level$ = STR$(level)
  274. _TITLE "Level: " + level$ + "   Score: " + score$
  275. IF score / 2000 = INT(score / 2000) THEN
  276.     level = level + 1
  277.     level$ = STR$(level)
  278.     _TITLE "Level: " + level$ + "   Score: " + score$
  279.     IF level = 21 THEN GOTO win:
  280.     GOTO start2:
  281.  
  282. done:
  283. LOCATE 10, 45: PRINT "G A M E     O V E R"
  284. FOR snd = 450 TO 150 STEP -25
  285.     SOUND snd, .5
  286. NEXT snd
  287. LOCATE 13, 45: PRINT "Again (Y/N)?"
  288. ag:
  289. ag$ = INKEY$
  290. IF ag$ = "y" OR ag$ = "Y" THEN GOTO start:
  291. IF ag$ = "n" OR ag$ = "N" THEN END
  292. GOTO ag:
  293.  
  294. win:
  295. LOCATE 10, 45: PRINT "G A M E     W O N ! ! ! ! ! ! !"
  296. FOR snd = 450 TO 150 STEP -25
  297.     SOUND snd, .5
  298. NEXT snd
  299. LOCATE 13, 45: PRINT "Again (Y/N)?"
  300. ag2:
  301. ag$ = INKEY$
  302. IF ag$ = "y" OR ag$ = "Y" THEN GOTO start:
  303. IF ag$ = "n" OR ag$ = "N" THEN END
  304. GOTO ag2:
  305.  
  306. 'Thanks to FelippeHeitor for this Sub and the camera code above.
  307. SUB adjustCamera
  308.     IF player.x + camera.x > _WIDTH / 2 OR player.x + camera.x < _WIDTH / 2 THEN
  309.         camera.x = _WIDTH / 2 - player.x
  310.     END IF
  311.     IF camera.x > 0 THEN camera.x = 0
  312.     IF camera.x < -(_WIDTH(map) - _WIDTH) THEN camera.x = -(_WIDTH(map) - _WIDTH)
  313.  
  314.     IF player.y + camera.y > _HEIGHT / 2 OR player.y + camera.y < _HEIGHT / 2 THEN
  315.         camera.y = _HEIGHT / 2 - player.y
  316.     END IF
  317.     IF camera.y > 0 THEN camera.y = 0
  318.     IF camera.y < -(_HEIGHT(map) - _HEIGHT) THEN camera.y = -(_HEIGHT(map) - _HEIGHT)
  319.  
Title: Re: Find The Gold!
Post by: SierraKen on October 25, 2020, 12:39:50 pm
I just fixed the Title Bar. I forgot to check it when I was trying something on it and it was just saying "Loading...". It works better now too.
Here is also a picture of the new trees. :)

Code: QB64: [Select]
  1. 'Find the Gold! by SierraKen
  2. 'October 24, 2020
  3. 'Thanks for the great mapping code by FellipeHeitor and help from B+!
  4. 'Additions:
  5. 'Body, Arms, and Legs. Levels and 20 gold per level. Larger land area sizes. Lakes and Trees. 20 Level limit.
  6. 'Changed PAINT to CLS , _RGB32(0,200,0) which greatly improves the loading speed.
  7. 'Added 4 times the amount of trees and made 3 levels of mountains.
  8. 'Added random creeks. Added twice the lakes with random shapes.
  9. 'Changed screen size to 800 x 600 to be compatible with all players.
  10. 'Added 100 seconds to level time, to 400 for level 1.
  11. 'Slowed player speed from 10 to 8.
  12. 'Changed to a happier sound when getting gold.
  13. 'Changed color after you get the gold from brown to green.
  14. 'Added WASD keys to move player along with arrow keys.
  15. 'Removed the square mountains and made more realistic hills.
  16. 'Put the lakes on the ground, before everything else.
  17. 'Made trees look better.
  18. 'Removed creeks.
  19. 'Fixed Title Bar.
  20.  
  21. SCREEN _NEWIMAGE(800, 600, 32)
  22.  
  23. TYPE object
  24.     x AS SINGLE
  25.     y AS SINGLE
  26.  
  27. DIM SHARED player AS object
  28. DIM SHARED camera AS object
  29. DIM playerSpeed AS SINGLE
  30.  
  31. _TITLE "Loading....."
  32.  
  33. start:
  34. score = 0
  35. level = 1
  36.  
  37. start2:
  38. player.x = _WIDTH / 2
  39. player.y = _HEIGHT / 2
  40.  
  41. map = _NEWIMAGE(_WIDTH * 7, _HEIGHT * 7, 32)
  42.  
  43. _DEST map
  44.  
  45. CLS , _RGB32(0, 200, 0)
  46. _LIMIT 2000
  47.  
  48. 'Lakes
  49. FOR lakes = 1 TO 100
  50.     w = RND
  51.     h = RND
  52.     sze = (RND * 250) + 100
  53.     shape = RND
  54.     FOR sz = .25 TO sze STEP .25
  55.         CIRCLE (w * _WIDTH, h * _HEIGHT), sz, _RGB32(0, 128, 255), , , shape
  56.     NEXT sz
  57. NEXT lakes
  58.  
  59.  
  60. 'Hills
  61. FOR hills = 1 TO 1200
  62.     xx = (RND * _WIDTH)
  63.     sz = INT(RND * 100) + 200
  64.     shape = RND
  65.     hillcolors:
  66.     c1 = INT(RND * 100) + 55
  67.     c2 = INT(RND * 100) + 55
  68.     c3 = INT(RND * 100) + 55
  69.     IF c1 = 255 AND c2 = 255 AND c3 = 128 THEN GOTO hillcolors:
  70.     yy = yy + 4
  71.     FOR hill = 1 TO sz STEP .25
  72.         hh = hh + .025
  73.         IF hh > 100 THEN hh = 100
  74.         cc1 = c1 + hh
  75.         cc2 = c2 + hh
  76.         cc3 = c3 + hh
  77.         CIRCLE (xx, yy), hill, _RGB32(cc1, cc2, cc3), 2 * _PI, _PI, shape
  78.     NEXT hill
  79.     hh = 0
  80. NEXT hills
  81. yy = 0
  82.  
  83.  
  84. 'Trees
  85. FOR trees = 1 TO 1000
  86.     tx = RND
  87.     tx = tx * _WIDTH
  88.     ty = RND
  89.     ty = ty * _HEIGHT
  90.     tsz = (RND * 40) + 10
  91.     LINE (tx, ty)-(tx, ty + tsz + 5), _RGB32(188, 127, 127)
  92.     FOR branches = ty TO ty + tsz STEP 3
  93.         trim = trim + 2
  94.         LINE (tx, branches)-(tx - trim, branches + 5), _RGB32(0, 183, 127)
  95.         LINE (tx, branches)-(tx + trim, branches + 5), _RGB32(0, 183, 127)
  96.     NEXT branches
  97.     trim = 0
  98. NEXT trees
  99.  
  100. 'Place Gold
  101. FOR gold = 1 TO 20
  102.     gold:
  103.     w2 = INT(RND * _WIDTH) - 40
  104.     h2 = INT(RND * _HEIGHT) - 40
  105.     IF w2 < 40 THEN w2 = 40
  106.     IF h2 < 40 THEN h2 = 40
  107.     IF POINT(w2, h2) = _RGB32(255, 255, 128) THEN GOTO gold:
  108.     IF POINT(w2, h2) = _RGB32(0, 0, 0) THEN GOTO gold:
  109.     'Gold
  110.     COLOR _RGB32(0, 0, 0), _RGB32(255, 255, 128)
  111.     _PRINTSTRING (w2, h2), "GOLD"
  112. NEXT gold
  113.  
  114.  
  115.  
  116. playerSpeed = 8
  117.  
  118. CONST keyUP = 18432
  119. CONST keyDOWN = 20480
  120. CONST keyLEFT = 19200
  121. CONST keyRIGHT = 19712
  122. CONST keyESC = 27
  123. _PUTIMAGE (camera.x, camera.y), map
  124.  
  125. LOCATE 3, 30: PRINT "Use the arrow keys (or WASD keys) to find 20 gold bars per level."
  126. LOCATE 4, 30: PRINT "Every level will have a shorter time."
  127. LOCATE 5, 30: PRINT "After Level 20 you win the game."
  128. LOCATE 10, 40: PRINT "Press Any Key To Begin."
  129. _TITLE "Find The Gold!"
  130. pause:
  131. a$ = INKEY$
  132. IF a$ <> "" THEN GOTO begin:
  133. GOTO pause:
  134. score$ = STR$(score)
  135. level$ = STR$(level)
  136.  
  137.  
  138. begin:
  139. _TITLE "Level: " + level$ + "   Score: " + score$
  140. seconds = INT(TIMER)
  141.     CLS
  142.     leveltime = level * 5
  143.     gametime = (405 - leveltime) - (INT(TIMER) - seconds)
  144.     _PUTIMAGE (camera.x, camera.y), map
  145.     LOCATE 1, 1: PRINT "Time Left: "; gametime
  146.     IF gametime < 1 THEN GOTO done:
  147.     IF _KEYDOWN(keyUP) OR _KEYDOWN(119) THEN
  148.         player.y = player.y - playerSpeed
  149.         t = t + 1
  150.     END IF
  151.     IF _KEYDOWN(keyDOWN) OR _KEYDOWN(115) THEN
  152.         player.y = player.y + playerSpeed
  153.         t = t + 1
  154.     END IF
  155.     IF _KEYDOWN(keyLEFT) OR _KEYDOWN(97) THEN
  156.         player.x = player.x - playerSpeed
  157.         t = t + 1
  158.     END IF
  159.     IF _KEYDOWN(keyRIGHT) OR _KEYDOWN(100) THEN
  160.         player.x = player.x + playerSpeed
  161.         t = t + 1
  162.     END IF
  163.     IF _KEYDOWN(keyESC) THEN END
  164.     IF player.x < 0 THEN player.x = 0
  165.     IF player.x > _WIDTH(map) THEN player.x = _WIDTH(map)
  166.     IF player.y < 0 THEN player.y = 0
  167.     IF player.y > _HEIGHT(map) THEN player.y = _HEIGHT(map)
  168.  
  169.     adjustCamera
  170.  
  171.     'Draw Head
  172.     FOR sz = .25 TO 10 STEP .25
  173.         CIRCLE (player.x + camera.x, player.y + camera.y), sz, _RGB32(255, 166, 127)
  174.     NEXT sz
  175.     'Draw Smile
  176.     CIRCLE (player.x + camera.x, player.y + camera.y + 2), 7, _RGB32(255, 0, 0), _PI, 2 * _PI, .5
  177.     'Draw Eyes
  178.     CIRCLE (player.x + camera.x - 4, player.y + camera.y - 2), 1, _RGB32(0, 0, 255)
  179.     CIRCLE (player.x + camera.x + 4, player.y + camera.y - 2), 1, _RGB32(0, 0, 255)
  180.     'hat
  181.     LINE (player.x + camera.x - 10, player.y + camera.y - 10)-(player.x + camera.x + 10, player.y + camera.y - 9), _RGB32(155, 0, 0), BF
  182.     LINE (player.x + camera.x - 5, player.y + camera.y - 9)-(player.x + camera.x + 5, player.y + camera.y - 15), _RGB32(155, 0, 0), BF
  183.     'body
  184.     LINE (player.x + camera.x, player.y + camera.y + 10)-(player.x + camera.x, player.y + camera.y + 20), _RGB32(155, 0, 0)
  185.  
  186.     IF t > 7 THEN t = 0
  187.  
  188.     'rest of body
  189.     IF t = 0 THEN
  190.         'left arm
  191.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 15, player.y + camera.y + 25), _RGB32(155, 0, 0)
  192.         'right arm
  193.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 15, player.y + camera.y + 25), _RGB32(155, 0, 0)
  194.         'left leg
  195.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 15, player.y + camera.y + 35), _RGB32(155, 0, 0)
  196.         'right leg
  197.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 15, player.y + camera.y + 35), _RGB32(155, 0, 0)
  198.     END IF
  199.  
  200.     IF t = 1 OR t = 7 THEN
  201.         'left arm
  202.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 11, player.y + camera.y + 25), _RGB32(155, 0, 0)
  203.         'right arm
  204.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 11, player.y + camera.y + 25), _RGB32(155, 0, 0)
  205.         'left leg
  206.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 11, player.y + camera.y + 35), _RGB32(155, 0, 0)
  207.         'right leg
  208.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 11, player.y + camera.y + 35), _RGB32(155, 0, 0)
  209.     END IF
  210.  
  211.     IF t = 2 OR t = 6 THEN
  212.         'left arm
  213.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 9, player.y + camera.y + 24), _RGB32(155, 0, 0)
  214.         'right arm
  215.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 9, player.y + camera.y + 24), _RGB32(155, 0, 0)
  216.         'left leg
  217.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 9, player.y + camera.y + 35), _RGB32(155, 0, 0)
  218.         'right leg
  219.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 9, player.y + camera.y + 35), _RGB32(155, 0, 0)
  220.     END IF
  221.  
  222.     IF t = 3 OR t = 5 THEN
  223.         'left arm
  224.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 7, player.y + camera.y + 24), _RGB32(155, 0, 0)
  225.         'right arm
  226.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 7, player.y + camera.y + 24), _RGB32(155, 0, 0)
  227.         'left leg
  228.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 7, player.y + camera.y + 35), _RGB32(155, 0, 0)
  229.         'right leg
  230.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 7, player.y + camera.y + 35), _RGB32(155, 0, 0)
  231.     END IF
  232.  
  233.     IF t = 4 THEN
  234.         'left arm
  235.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 5, player.y + camera.y + 23), _RGB32(155, 0, 0)
  236.         'right arm
  237.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 5, player.y + camera.y + 23), _RGB32(155, 0, 0)
  238.         'left leg
  239.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 5, player.y + camera.y + 35), _RGB32(155, 0, 0)
  240.         'right leg
  241.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 5, player.y + camera.y + 35), _RGB32(155, 0, 0)
  242.     END IF
  243.  
  244.  
  245.     FOR check = -15 TO 15
  246.         IF POINT(player.x + check, player.y + check) = _RGB32(255, 255, 128) THEN
  247.             _DEST map
  248.             FOR sz = .2 TO 35 STEP .2
  249.                 CIRCLE (player.x + check, player.y + check), sz, _RGB32(127, 255, 127)
  250.             NEXT sz
  251.             GOSUB findgold:
  252.         END IF
  253.         IF POINT(player.x + check, player.y - check) = _RGB32(255, 255, 128) THEN
  254.             _DEST map
  255.             FOR sz = .2 TO 35 STEP .2
  256.                 CIRCLE (player.x + check, player.y - check), sz, _RGB32(127, 255, 127)
  257.             NEXT sz
  258.             GOSUB findgold:
  259.         END IF
  260.         IF POINT(player.x - check, player.y + check) = _RGB32(255, 255, 128) THEN
  261.             _DEST map
  262.             FOR sz = .2 TO 35 STEP .2
  263.                 CIRCLE (player.x - check, player.y + check), sz, _RGB32(127, 255, 127)
  264.             NEXT sz
  265.             GOSUB findgold:
  266.         END IF
  267.     NEXT check
  268.     _DISPLAY
  269.     _LIMIT 60
  270.  
  271. findgold:
  272. FOR snd = 400 TO 800 STEP 100
  273.     SOUND snd, .5
  274. NEXT snd
  275. score = score + 100
  276. score$ = STR$(score)
  277. level$ = STR$(level)
  278. _TITLE "Level: " + level$ + "   Score: " + score$
  279. IF score / 2000 = INT(score / 2000) THEN
  280.     level = level + 1
  281.     level$ = STR$(level)
  282.     _TITLE "Level: " + level$ + "   Score: " + score$
  283.     IF level = 21 THEN GOTO win:
  284.     GOTO start2:
  285.  
  286. done:
  287. LOCATE 10, 45: PRINT "G A M E     O V E R"
  288. FOR snd = 450 TO 150 STEP -25
  289.     SOUND snd, .5
  290. NEXT snd
  291. LOCATE 13, 45: PRINT "Again (Y/N)?"
  292. ag:
  293. ag$ = INKEY$
  294. IF ag$ = "y" OR ag$ = "Y" THEN GOTO start:
  295. IF ag$ = "n" OR ag$ = "N" THEN END
  296. GOTO ag:
  297.  
  298. win:
  299. LOCATE 10, 45: PRINT "G A M E     W O N ! ! ! ! ! ! !"
  300. FOR snd = 450 TO 150 STEP -25
  301.     SOUND snd, .5
  302. NEXT snd
  303. LOCATE 13, 45: PRINT "Again (Y/N)?"
  304. ag2:
  305. ag$ = INKEY$
  306. IF ag$ = "y" OR ag$ = "Y" THEN GOTO start:
  307. IF ag$ = "n" OR ag$ = "N" THEN END
  308. GOTO ag2:
  309.  
  310. 'Thanks to FelippeHeitor for this Sub and the camera code above.
  311. SUB adjustCamera
  312.     IF player.x + camera.x > _WIDTH / 2 OR player.x + camera.x < _WIDTH / 2 THEN
  313.         camera.x = _WIDTH / 2 - player.x
  314.     END IF
  315.     IF camera.x > 0 THEN camera.x = 0
  316.     IF camera.x < -(_WIDTH(map) - _WIDTH) THEN camera.x = -(_WIDTH(map) - _WIDTH)
  317.  
  318.     IF player.y + camera.y > _HEIGHT / 2 OR player.y + camera.y < _HEIGHT / 2 THEN
  319.         camera.y = _HEIGHT / 2 - player.y
  320.     END IF
  321.     IF camera.y > 0 THEN camera.y = 0
  322.     IF camera.y < -(_HEIGHT(map) - _HEIGHT) THEN camera.y = -(_HEIGHT(map) - _HEIGHT)
  323.  
Title: Re: Find The Gold!
Post by: bplus on October 25, 2020, 01:09:20 pm
Ah tree shapes much better! Can you do heights according to distance away ie the higher up in landscape the smaller the trees? Something to try...

Also do you know how to vary browns and greens? Formula for Brown is 3 parts red + 2 parts green + 1 part Blue
So really really dark brown is _RGB32(30, 20, 10) probably looks black but
60, 40, 20 might serve plus some randomness of course
and tans and beige is like 255, 128, 64 really light,  200, 100, 50 darker...

Greens browned up by adding red and blue grass is made by adding... well blue of course ;-)) but always way less than amount of green.

Hills would get bluer as recede into background because more air and reflecting more sky like lakes and oceans only more subtle because 0 smooth surfaces.
Title: Re: Find The Gold!
Post by: Aurel on October 25, 2020, 02:23:12 pm
The last one looking really good ..
If you can add obstacles then you will made really cool simple game !

https://aurelsoft.ucoz.com/FindGold5.png (https://aurelsoft.ucoz.com/FindGold5.png)
Title: Re: Find The Gold!
Post by: SierraKen on October 25, 2020, 02:26:55 pm
Awesome! I just used your browns and as you go down further the hills turn more yellow, which also makes it a little harder to find the GOLD as you get down lower. It also looks like the color of the foothills as you get closer. This is way cool! Thanks.

Code: QB64: [Select]
  1. 'Find the Gold! by SierraKen
  2. 'October 24, 2020
  3. 'Thanks for the great mapping code by FellipeHeitor and help from B+!
  4. 'Additions:
  5. 'Body, Arms, and Legs. Levels and 20 gold per level. Larger land area sizes. Lakes and Trees. 20 Level limit.
  6. 'Changed PAINT to CLS , _RGB32(0,200,0) which greatly improves the loading speed.
  7. 'Added 4 times the amount of trees and made 3 levels of mountains.
  8. 'Added random creeks. Added twice the lakes with random shapes.
  9. 'Changed screen size to 800 x 600 to be compatible with all players.
  10. 'Added 100 seconds to level time, to 400 for level 1.
  11. 'Slowed player speed from 10 to 8.
  12. 'Changed to a happier sound when getting gold.
  13. 'Changed color after you get the gold from brown to green.
  14. 'Added WASD keys to move player along with arrow keys.
  15. 'Removed the square mountains and made more realistic hills.
  16. 'Put the lakes on the ground, before everything else.
  17. 'Made trees look better.
  18. 'Removed creeks.
  19. 'Fixed Title Bar.
  20. 'Changed colors of hills.
  21.  
  22. SCREEN _NEWIMAGE(800, 600, 32)
  23.  
  24. TYPE object
  25.     x AS SINGLE
  26.     y AS SINGLE
  27.  
  28. DIM SHARED player AS object
  29. DIM SHARED camera AS object
  30. DIM playerSpeed AS SINGLE
  31.  
  32. _TITLE "Loading....."
  33.  
  34. start:
  35. score = 0
  36. level = 1
  37.  
  38. start2:
  39. player.x = _WIDTH / 2
  40. player.y = _HEIGHT / 2
  41.  
  42. map = _NEWIMAGE(_WIDTH * 7, _HEIGHT * 7, 32)
  43.  
  44. _DEST map
  45.  
  46. CLS , _RGB32(0, 200, 0)
  47. _LIMIT 2000
  48.  
  49. 'Lakes
  50. FOR lakes = 1 TO 100
  51.     w = RND
  52.     h = RND
  53.     sze = (RND * 250) + 100
  54.     shape = RND
  55.     FOR sz = .25 TO sze STEP .25
  56.         CIRCLE (w * _WIDTH, h * _HEIGHT), sz, _RGB32(0, 128, 255), , , shape
  57.     NEXT sz
  58. NEXT lakes
  59.  
  60.  
  61. 'Hills
  62. FOR hills = 1 TO 1200
  63.     xx = (RND * _WIDTH)
  64.     sz = INT(RND * 100) + 200
  65.     shape = RND
  66.     hillcolors:
  67.     blue = blue + .05
  68.     c3 = INT(RND * 50) + 20 + blue
  69.     c2 = c3 * 2
  70.     c1 = c3 * 3
  71.     IF c1 = 255 AND c2 = 255 AND c3 = 128 THEN GOTO hillcolors:
  72.     yy = yy + 4
  73.     FOR hill = 1 TO sz STEP .25
  74.         hh = hh + .025
  75.         IF hh > 100 THEN hh = 100
  76.         cc1 = c1 + hh
  77.         cc2 = c2 + hh
  78.         cc3 = c3 + hh
  79.         CIRCLE (xx, yy), hill, _RGB32(cc1, cc2, cc3), 2 * _PI, _PI, shape
  80.     NEXT hill
  81.     hh = 0
  82. NEXT hills
  83. blue = 0
  84. yy = 0
  85.  
  86.  
  87. 'Trees
  88. FOR trees = 1 TO 1000
  89.     tx = RND
  90.     tx = tx * _WIDTH
  91.     ty = RND
  92.     ty = ty * _HEIGHT
  93.     tsz = (RND * 40) + 10
  94.     LINE (tx, ty)-(tx, ty + tsz + 5), _RGB32(188, 127, 127)
  95.     FOR branches = ty TO ty + tsz STEP 3
  96.         trim = trim + 2
  97.         LINE (tx, branches)-(tx - trim, branches + 5), _RGB32(0, 183, 127)
  98.         LINE (tx, branches)-(tx + trim, branches + 5), _RGB32(0, 183, 127)
  99.     NEXT branches
  100.     trim = 0
  101. NEXT trees
  102.  
  103. 'Place Gold
  104. FOR gold = 1 TO 20
  105.     gold:
  106.     w2 = INT(RND * _WIDTH) - 40
  107.     h2 = INT(RND * _HEIGHT) - 40
  108.     IF w2 < 40 THEN w2 = 40
  109.     IF h2 < 40 THEN h2 = 40
  110.     IF POINT(w2, h2) = _RGB32(255, 255, 128) THEN GOTO gold:
  111.     IF POINT(w2, h2) = _RGB32(0, 0, 0) THEN GOTO gold:
  112.     'Gold
  113.     COLOR _RGB32(0, 0, 0), _RGB32(255, 255, 128)
  114.     _PRINTSTRING (w2, h2), "GOLD"
  115. NEXT gold
  116.  
  117.  
  118.  
  119. playerSpeed = 8
  120.  
  121. CONST keyUP = 18432
  122. CONST keyDOWN = 20480
  123. CONST keyLEFT = 19200
  124. CONST keyRIGHT = 19712
  125. CONST keyESC = 27
  126. _PUTIMAGE (camera.x, camera.y), map
  127.  
  128. LOCATE 3, 30: PRINT "Use the arrow keys (or WASD keys) to find 20 gold bars per level."
  129. LOCATE 4, 30: PRINT "Every level will have a shorter time."
  130. LOCATE 5, 30: PRINT "After Level 20 you win the game."
  131. LOCATE 10, 40: PRINT "Press Any Key To Begin."
  132. _TITLE "Find The Gold!"
  133. pause:
  134. a$ = INKEY$
  135. IF a$ <> "" THEN GOTO begin:
  136. GOTO pause:
  137. score$ = STR$(score)
  138. level$ = STR$(level)
  139.  
  140.  
  141. begin:
  142. _TITLE "Level: " + level$ + "   Score: " + score$
  143. seconds = INT(TIMER)
  144.     CLS
  145.     leveltime = level * 5
  146.     gametime = (405 - leveltime) - (INT(TIMER) - seconds)
  147.     _PUTIMAGE (camera.x, camera.y), map
  148.     LOCATE 1, 1: PRINT "Time Left: "; gametime
  149.     IF gametime < 1 THEN GOTO done:
  150.     IF _KEYDOWN(keyUP) OR _KEYDOWN(119) THEN
  151.         player.y = player.y - playerSpeed
  152.         t = t + 1
  153.     END IF
  154.     IF _KEYDOWN(keyDOWN) OR _KEYDOWN(115) THEN
  155.         player.y = player.y + playerSpeed
  156.         t = t + 1
  157.     END IF
  158.     IF _KEYDOWN(keyLEFT) OR _KEYDOWN(97) THEN
  159.         player.x = player.x - playerSpeed
  160.         t = t + 1
  161.     END IF
  162.     IF _KEYDOWN(keyRIGHT) OR _KEYDOWN(100) THEN
  163.         player.x = player.x + playerSpeed
  164.         t = t + 1
  165.     END IF
  166.     IF _KEYDOWN(keyESC) THEN END
  167.     IF player.x < 0 THEN player.x = 0
  168.     IF player.x > _WIDTH(map) THEN player.x = _WIDTH(map)
  169.     IF player.y < 0 THEN player.y = 0
  170.     IF player.y > _HEIGHT(map) THEN player.y = _HEIGHT(map)
  171.  
  172.     adjustCamera
  173.  
  174.     'Draw Head
  175.     FOR sz = .25 TO 10 STEP .25
  176.         CIRCLE (player.x + camera.x, player.y + camera.y), sz, _RGB32(255, 166, 127)
  177.     NEXT sz
  178.     'Draw Smile
  179.     CIRCLE (player.x + camera.x, player.y + camera.y + 2), 7, _RGB32(255, 0, 0), _PI, 2 * _PI, .5
  180.     'Draw Eyes
  181.     CIRCLE (player.x + camera.x - 4, player.y + camera.y - 2), 1, _RGB32(0, 0, 255)
  182.     CIRCLE (player.x + camera.x + 4, player.y + camera.y - 2), 1, _RGB32(0, 0, 255)
  183.     'hat
  184.     LINE (player.x + camera.x - 10, player.y + camera.y - 10)-(player.x + camera.x + 10, player.y + camera.y - 9), _RGB32(155, 0, 0), BF
  185.     LINE (player.x + camera.x - 5, player.y + camera.y - 9)-(player.x + camera.x + 5, player.y + camera.y - 15), _RGB32(155, 0, 0), BF
  186.     'body
  187.     LINE (player.x + camera.x, player.y + camera.y + 10)-(player.x + camera.x, player.y + camera.y + 20), _RGB32(155, 0, 0)
  188.  
  189.     IF t > 7 THEN t = 0
  190.  
  191.     'rest of body
  192.     IF t = 0 THEN
  193.         'left arm
  194.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 15, player.y + camera.y + 25), _RGB32(155, 0, 0)
  195.         'right arm
  196.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 15, player.y + camera.y + 25), _RGB32(155, 0, 0)
  197.         'left leg
  198.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 15, player.y + camera.y + 35), _RGB32(155, 0, 0)
  199.         'right leg
  200.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 15, player.y + camera.y + 35), _RGB32(155, 0, 0)
  201.     END IF
  202.  
  203.     IF t = 1 OR t = 7 THEN
  204.         'left arm
  205.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 11, player.y + camera.y + 25), _RGB32(155, 0, 0)
  206.         'right arm
  207.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 11, player.y + camera.y + 25), _RGB32(155, 0, 0)
  208.         'left leg
  209.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 11, player.y + camera.y + 35), _RGB32(155, 0, 0)
  210.         'right leg
  211.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 11, player.y + camera.y + 35), _RGB32(155, 0, 0)
  212.     END IF
  213.  
  214.     IF t = 2 OR t = 6 THEN
  215.         'left arm
  216.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 9, player.y + camera.y + 24), _RGB32(155, 0, 0)
  217.         'right arm
  218.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 9, player.y + camera.y + 24), _RGB32(155, 0, 0)
  219.         'left leg
  220.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 9, player.y + camera.y + 35), _RGB32(155, 0, 0)
  221.         'right leg
  222.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 9, player.y + camera.y + 35), _RGB32(155, 0, 0)
  223.     END IF
  224.  
  225.     IF t = 3 OR t = 5 THEN
  226.         'left arm
  227.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 7, player.y + camera.y + 24), _RGB32(155, 0, 0)
  228.         'right arm
  229.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 7, player.y + camera.y + 24), _RGB32(155, 0, 0)
  230.         'left leg
  231.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 7, player.y + camera.y + 35), _RGB32(155, 0, 0)
  232.         'right leg
  233.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 7, player.y + camera.y + 35), _RGB32(155, 0, 0)
  234.     END IF
  235.  
  236.     IF t = 4 THEN
  237.         'left arm
  238.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 5, player.y + camera.y + 23), _RGB32(155, 0, 0)
  239.         'right arm
  240.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 5, player.y + camera.y + 23), _RGB32(155, 0, 0)
  241.         'left leg
  242.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 5, player.y + camera.y + 35), _RGB32(155, 0, 0)
  243.         'right leg
  244.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 5, player.y + camera.y + 35), _RGB32(155, 0, 0)
  245.     END IF
  246.  
  247.  
  248.     FOR check = -15 TO 15
  249.         IF POINT(player.x + check, player.y + check) = _RGB32(255, 255, 128) THEN
  250.             _DEST map
  251.             FOR sz = .2 TO 35 STEP .2
  252.                 CIRCLE (player.x + check, player.y + check), sz, _RGB32(127, 255, 127)
  253.             NEXT sz
  254.             GOSUB findgold:
  255.         END IF
  256.         IF POINT(player.x + check, player.y - check) = _RGB32(255, 255, 128) THEN
  257.             _DEST map
  258.             FOR sz = .2 TO 35 STEP .2
  259.                 CIRCLE (player.x + check, player.y - check), sz, _RGB32(127, 255, 127)
  260.             NEXT sz
  261.             GOSUB findgold:
  262.         END IF
  263.         IF POINT(player.x - check, player.y + check) = _RGB32(255, 255, 128) THEN
  264.             _DEST map
  265.             FOR sz = .2 TO 35 STEP .2
  266.                 CIRCLE (player.x - check, player.y + check), sz, _RGB32(127, 255, 127)
  267.             NEXT sz
  268.             GOSUB findgold:
  269.         END IF
  270.     NEXT check
  271.     _DISPLAY
  272.     _LIMIT 60
  273.  
  274. findgold:
  275. FOR snd = 400 TO 800 STEP 100
  276.     SOUND snd, .5
  277. NEXT snd
  278. score = score + 100
  279. score$ = STR$(score)
  280. level$ = STR$(level)
  281. _TITLE "Level: " + level$ + "   Score: " + score$
  282. IF score / 2000 = INT(score / 2000) THEN
  283.     level = level + 1
  284.     level$ = STR$(level)
  285.     _TITLE "Level: " + level$ + "   Score: " + score$
  286.     IF level = 21 THEN GOTO win:
  287.     GOTO start2:
  288.  
  289. done:
  290. LOCATE 10, 45: PRINT "G A M E     O V E R"
  291. FOR snd = 450 TO 150 STEP -25
  292.     SOUND snd, .5
  293. NEXT snd
  294. LOCATE 13, 45: PRINT "Again (Y/N)?"
  295. ag:
  296. ag$ = INKEY$
  297. IF ag$ = "y" OR ag$ = "Y" THEN GOTO start:
  298. IF ag$ = "n" OR ag$ = "N" THEN END
  299. GOTO ag:
  300.  
  301. win:
  302. LOCATE 10, 45: PRINT "G A M E     W O N ! ! ! ! ! ! !"
  303. FOR snd = 450 TO 150 STEP -25
  304.     SOUND snd, .5
  305. NEXT snd
  306. LOCATE 13, 45: PRINT "Again (Y/N)?"
  307. ag2:
  308. ag$ = INKEY$
  309. IF ag$ = "y" OR ag$ = "Y" THEN GOTO start:
  310. IF ag$ = "n" OR ag$ = "N" THEN END
  311. GOTO ag2:
  312.  
  313. 'Thanks to FelippeHeitor for this Sub and the camera code above.
  314. SUB adjustCamera
  315.     IF player.x + camera.x > _WIDTH / 2 OR player.x + camera.x < _WIDTH / 2 THEN
  316.         camera.x = _WIDTH / 2 - player.x
  317.     END IF
  318.     IF camera.x > 0 THEN camera.x = 0
  319.     IF camera.x < -(_WIDTH(map) - _WIDTH) THEN camera.x = -(_WIDTH(map) - _WIDTH)
  320.  
  321.     IF player.y + camera.y > _HEIGHT / 2 OR player.y + camera.y < _HEIGHT / 2 THEN
  322.         camera.y = _HEIGHT / 2 - player.y
  323.     END IF
  324.     IF camera.y > 0 THEN camera.y = 0
  325.     IF camera.y < -(_HEIGHT(map) - _HEIGHT) THEN camera.y = -(_HEIGHT(map) - _HEIGHT)
  326.  
Title: Re: Find The Gold!
Post by: SierraKen on October 25, 2020, 02:28:04 pm
Aurel, that sounds like a great idea! I'll work on that toward the end of the week when my power comes back.
Title: Re: Find The Gold!
Post by: Aurel on October 25, 2020, 02:35:59 pm
Fine ...just take your time ..
oups i add link then i figured that i can use attachment ...hmmm
Title: Re: Find The Gold!
Post by: SierraKen on October 26, 2020, 05:40:38 pm
My power didn't go out after all so I've been working hard on this game today. I added mine shafts where if you run into one, it sends you to a random place on the map. And as you get high in the levels, more mine shafts are there to dodge. I reduced the 20 levels to win to 10 levels and added my own music I made many years ago. It was a program called Magix Music Creator on my old Windows XP computer. So I put that music file and the game in a zip file below in attachments. Enjoy and tell me what you think, thanks.

Title: Re: Find The Gold!
Post by: FellippeHeitor on October 26, 2020, 05:45:44 pm
This is progressing nicely, Ken!
Title: Re: Find The Gold!
Post by: SierraKen on October 26, 2020, 06:56:34 pm
Thanks Felippe. :) Next I might add some enemies and lives but we'll see. I like tinkering around with it. :)
Title: Re: Find The Gold!
Post by: bplus on October 27, 2020, 11:02:32 am
Yes, I like music, coordinates and mountain coloring: light towards front or down and darker bluer upwards to top.

The mountain coloring helps with visual bearings, maybe could go flat-lands and housing on left or right to help as visual clues where you are on map.

What would be really clever is thumbnail sketch were you've been on map.

Title: Re: Find The Gold!
Post by: SierraKen on October 27, 2020, 05:46:30 pm
Thanks for the ideas B+. I added 10 houses per level. I also added 5 extra gold bars per level to make it a little easier. You just need to get 20 to pass each level. I also added a map in the lower right-hand corner of the screen, which was pretty tricky but I figured it out. :) The gold dots are where the gold is located and you are the red dot. Since I use POINT in almost everything and not specific variable coordinates as you collect the gold, I wasn't able to make the gold dots disappear when you collect them. But I still like what I did.
The updated code is below and I also updated the zip file in the attachment below that includes the background music. I hope you all enjoy this. This will probably be the final version since I need a break on it. Maybe someday I'll come back and add more things. But for now, this is good. Below is a current photo.

Code: QB64: [Select]
  1. 'Find the Gold! by SierraKen
  2. 'October 27, 2020
  3. 'Thanks for the great mapping code by FellipeHeitor and help from B+ and ideas from Aurel!
  4. 'Newest Additions: Mine Shafts and Music.
  5. 'Music created by me many years ago.
  6. 'Added random houses on each level.
  7. 'Added 5 extra gold bars on each level.
  8. 'Added Map in lower right corner.
  9.  
  10. SCREEN _NEWIMAGE(800, 600, 32)
  11.  
  12. TYPE object
  13.     x AS SINGLE
  14.     y AS SINGLE
  15.  
  16. DIM SHARED player AS object
  17. DIM SHARED camera AS object
  18. DIM playerSpeed AS SINGLE
  19. DIM minelevel AS SINGLE
  20. DIM level AS SINGLE
  21. DIM score AS SINGLE
  22. DIM leveltime AS SINGLE
  23. DIM gametime AS SINGLE
  24. DIM seconds AS SINGLE
  25. DIM goldx(50), goldy(50)
  26.  
  27. _TITLE "Loading....."
  28. s& = _SNDOPEN("Hello_Martian_Home.mp3")
  29. start:
  30. minelevel = 50
  31. score = 0
  32. level = 1
  33.  
  34. start2:
  35. player.x = _WIDTH / 2
  36. player.y = _HEIGHT / 2
  37.  
  38. map = _NEWIMAGE(_WIDTH * 7, _HEIGHT * 7, 32)
  39.  
  40. _DEST map
  41.  
  42. CLS , _RGB32(0, 200, 0)
  43. _LIMIT 2000
  44.  
  45. 'Lakes
  46. FOR lakes = 1 TO 100
  47.     w = RND
  48.     h = RND
  49.     sze = (RND * 250) + 100
  50.     shape = RND
  51.     FOR sz = .25 TO sze STEP .25
  52.         CIRCLE (w * _WIDTH, h * _HEIGHT), sz, _RGB32(0, 128, 255), , , shape
  53.     NEXT sz
  54. NEXT lakes
  55.  
  56. 'Hills
  57. FOR hills = 1 TO 1200
  58.     xx = (RND * _WIDTH)
  59.     sz = INT(RND * 100) + 200
  60.     shape = RND
  61.     hillcolors:
  62.     blue = blue + .05
  63.     c3 = INT(RND * 50) + 20 + blue
  64.     c2 = c3 * 2
  65.     c1 = c3 * 3
  66.     IF c1 = 255 AND c2 = 255 AND c3 = 128 THEN GOTO hillcolors:
  67.     yy = yy + 4
  68.     FOR hill = 1 TO sz STEP .25
  69.         hh = hh + .025
  70.         IF hh > 100 THEN hh = 100
  71.         cc1 = c1 + hh
  72.         cc2 = c2 + hh
  73.         cc3 = c3 + hh
  74.         CIRCLE (xx, yy), hill, _RGB32(cc1, cc2, cc3), 2 * _PI, _PI, shape
  75.     NEXT hill
  76.     hh = 0
  77. NEXT hills
  78. blue = 0
  79. yy = 0
  80.  
  81. 'Trees
  82. FOR trees = 1 TO 1000
  83.     tx = RND
  84.     tx = tx * _WIDTH
  85.     ty = RND
  86.     ty = ty * _HEIGHT
  87.     tsz = (RND * 40) + 10
  88.     LINE (tx, ty)-(tx, ty + tsz + 5), _RGB32(188, 127, 127)
  89.     FOR branches = ty TO ty + tsz STEP 3
  90.         trim = trim + 2
  91.         LINE (tx, branches)-(tx - trim, branches + 5), _RGB32(0, 183, 127)
  92.         LINE (tx, branches)-(tx + trim, branches + 5), _RGB32(0, 183, 127)
  93.     NEXT branches
  94.     trim = 0
  95. NEXT trees
  96.  
  97. 'Mine Shafts
  98. FOR mines = 1 TO minelevel
  99.     mines:
  100.     bx = RND
  101.     bx = bx * _WIDTH
  102.     by = RND
  103.     by = by * _HEIGHT
  104.     IF bx < 500 AND by < 400 THEN GOTO mines:
  105.     FOR sz = .25 TO 10 STEP .25
  106.         CIRCLE (bx, by), sz, _RGB32(0, 0, 5)
  107.     NEXT sz
  108. NEXT mines
  109.  
  110. 'Houses
  111. FOR houses = 1 TO 10
  112.     xhouse = INT(RND * _WIDTH)
  113.     yhouse = INT(RND * _HEIGHT)
  114.     szhouse = INT(RND * 60) + 30
  115.     LINE (xhouse, yhouse)-(xhouse + szhouse, yhouse + szhouse), _RGB32(183, 161, 150), BF
  116.     'roof
  117.     FOR sz = .25 TO (szhouse / 2) STEP .25
  118.         CIRCLE (xhouse + (szhouse / 2), yhouse), sz, _RGB32(150, 105, 105), _PI * 2, _PI, .5
  119.     NEXT sz
  120.     'door
  121.     LINE (xhouse + (szhouse / 2) - szhouse * .1, yhouse + szhouse - 15)-(xhouse + (szhouse / 2) + szhouse * .1, yhouse + szhouse), _RGB32(150, 105, 105), BF
  122.     'windows
  123.     LINE (xhouse + szhouse * .2, yhouse + szhouse * .2)-(xhouse + szhouse * .4, yhouse + szhouse * .4), _RGB32(150, 105, 105), BF
  124.     LINE (xhouse + szhouse * .6, yhouse + szhouse * .2)-(xhouse + szhouse * .8, yhouse + szhouse * .4), _RGB32(150, 105, 105), BF
  125. NEXT houses
  126.  
  127.  
  128. 'Place Gold
  129. FOR gold = 1 TO 25
  130.     gold:
  131.     w2 = INT(RND * _WIDTH) - 40
  132.     h2 = INT(RND * _HEIGHT) - 40
  133.     goldx(gold) = w2
  134.     goldy(gold) = h2
  135.     IF w2 < 40 THEN w2 = 40
  136.     IF h2 < 40 THEN h2 = 40
  137.     IF h2 > (_HEIGHT - 150) THEN GOTO gold:
  138.     IF POINT(w2, h2) = _RGB32(255, 255, 128) THEN GOTO gold:
  139.     IF POINT(w2, h2) = _RGB32(0, 0, 0) THEN GOTO gold:
  140.     IF POINT(w2, h2) = _RGB32(0, 0, 5) THEN GOTO gold:
  141.     FOR check = -10 TO 10
  142.         IF POINT(w2 + check, h2 + check) = _RGB32(183, 161, 150) THEN GOTO gold:
  143.         IF POINT(w2 + check, h2 + check) = _RGB32(150, 105, 105) THEN GOTO gold:
  144.     NEXT check
  145.     'Gold
  146.     COLOR _RGB32(0, 0, 0), _RGB32(255, 255, 128)
  147.     _PRINTSTRING (w2, h2), "GOLD"
  148. NEXT gold
  149.  
  150.  
  151.  
  152. IF level > 1 THEN GOTO begin:
  153.  
  154. playerSpeed = 8
  155.  
  156. CONST keyUP = 18432
  157. CONST keyDOWN = 20480
  158. CONST keyLEFT = 19200
  159. CONST keyRIGHT = 19712
  160. CONST keyESC = 27
  161. _PUTIMAGE (camera.x, camera.y), map
  162.  
  163. LOCATE 3, 22: PRINT "Use the arrow keys (or WASD keys) to find 20 gold bars per level."
  164. LOCATE 4, 22: PRINT "To make it a little easier, there are 25 gold bars on each level."
  165. LOCATE 5, 22: PRINT "Every level will have a shorter time."
  166. LOCATE 6, 22: PRINT "After Level 10 you win the game."
  167. LOCATE 7, 22: PRINT "Be careful not to step in the black mine shafts or they will send"
  168. LOCATE 8, 22: PRINT "you to a random location."
  169. LOCATE 9, 22: PRINT "Every level will have more mine shafts."
  170. LOCATE 10, 22: PRINT "Use the Map in the lower right corner to see where the gold is placed."
  171. LOCATE 11, 22: PRINT "Map will not remove gold dot after you have picked it up."
  172. LOCATE 12, 22: PRINT "You show up on the map as a red dot."
  173. LOCATE 14, 22: PRINT "Game and Music created by SierraKen."
  174. LOCATE 17, 32: PRINT "* Press Any Key To Begin. *"
  175. _TITLE "Find The Gold!"
  176. pause:
  177. a$ = INKEY$
  178. IF a$ <> "" THEN GOTO begin:
  179. GOTO pause:
  180.  
  181. begin:
  182. score$ = STR$(score)
  183. level$ = STR$(level)
  184. _TITLE "Level: " + level$ + "   Score: " + score$
  185. seconds = INT(TIMER)
  186.     CLS
  187.     leveltime = level * 10
  188.     gametime = (410 - leveltime) - (INT(TIMER) - seconds)
  189.     _PUTIMAGE (camera.x, camera.y), map
  190.     LOCATE 1, 1: PRINT "Time Left: "; gametime
  191.     IF gametime < 1 THEN GOTO done:
  192.     IF _KEYDOWN(keyUP) OR _KEYDOWN(119) THEN
  193.         player.y = player.y - playerSpeed
  194.         t = t + 1
  195.         score$ = STR$(score)
  196.         level$ = STR$(level)
  197.         coordx$ = STR$(player.x)
  198.         coordy$ = STR$(player.y)
  199.         _TITLE "Level: " + level$ + "   Score: " + score$ + "                         Coordinates: " + coordx$ + "," + coordy$
  200.     END IF
  201.     IF _KEYDOWN(keyDOWN) OR _KEYDOWN(115) THEN
  202.         player.y = player.y + playerSpeed
  203.         t = t + 1
  204.         score$ = STR$(score)
  205.         level$ = STR$(level)
  206.         coordx$ = STR$(player.x)
  207.         coordy$ = STR$(player.y)
  208.         _TITLE "Level: " + level$ + "   Score: " + score$ + "                         Coordinates: " + coordx$ + "," + coordy$
  209.     END IF
  210.     IF _KEYDOWN(keyLEFT) OR _KEYDOWN(97) THEN
  211.         player.x = player.x - playerSpeed
  212.         t = t + 1
  213.         score$ = STR$(score)
  214.         level$ = STR$(level)
  215.         coordx$ = STR$(player.x)
  216.         coordy$ = STR$(player.y)
  217.         _TITLE "Level: " + level$ + "   Score: " + score$ + "                         Coordinates: " + coordx$ + "," + coordy$
  218.     END IF
  219.     IF _KEYDOWN(keyRIGHT) OR _KEYDOWN(100) THEN
  220.         player.x = player.x + playerSpeed
  221.         t = t + 1
  222.         score$ = STR$(score)
  223.         level$ = STR$(level)
  224.         coordx$ = STR$(player.x)
  225.         coordy$ = STR$(player.y)
  226.         _TITLE "Level: " + level$ + "   Score: " + score$ + "                         Coordinates: " + coordx$ + "," + coordy$
  227.     END IF
  228.     IF _KEYDOWN(keyESC) THEN END
  229.     IF player.x < 0 THEN player.x = 0
  230.     IF player.x > _WIDTH(map) THEN player.x = _WIDTH(map)
  231.     IF player.y < 0 THEN player.y = 0
  232.     IF player.y > _HEIGHT(map) THEN player.y = _HEIGHT(map)
  233.  
  234.     adjustCamera
  235.  
  236.     'Draw Head
  237.     FOR sz = .25 TO 10 STEP .25
  238.         CIRCLE (player.x + camera.x, player.y + camera.y), sz, _RGB32(255, 166, 127)
  239.     NEXT sz
  240.     'Draw Smile
  241.     CIRCLE (player.x + camera.x, player.y + camera.y + 2), 7, _RGB32(255, 0, 0), _PI, 2 * _PI, .5
  242.     'Draw Eyes
  243.     CIRCLE (player.x + camera.x - 4, player.y + camera.y - 2), 1, _RGB32(0, 0, 255)
  244.     CIRCLE (player.x + camera.x + 4, player.y + camera.y - 2), 1, _RGB32(0, 0, 255)
  245.     'hat
  246.     LINE (player.x + camera.x - 10, player.y + camera.y - 10)-(player.x + camera.x + 10, player.y + camera.y - 9), _RGB32(155, 0, 0), BF
  247.     LINE (player.x + camera.x - 5, player.y + camera.y - 9)-(player.x + camera.x + 5, player.y + camera.y - 15), _RGB32(155, 0, 0), BF
  248.     'body
  249.     LINE (player.x + camera.x, player.y + camera.y + 10)-(player.x + camera.x, player.y + camera.y + 20), _RGB32(155, 0, 0)
  250.  
  251.     IF t > 7 THEN t = 0
  252.  
  253.     'rest of body
  254.     IF t = 0 THEN
  255.         'left arm
  256.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 15, player.y + camera.y + 25), _RGB32(155, 0, 0)
  257.         'right arm
  258.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 15, player.y + camera.y + 25), _RGB32(155, 0, 0)
  259.         'left leg
  260.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 15, player.y + camera.y + 35), _RGB32(155, 0, 0)
  261.         'right leg
  262.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 15, player.y + camera.y + 35), _RGB32(155, 0, 0)
  263.     END IF
  264.  
  265.     IF t = 1 OR t = 7 THEN
  266.         'left arm
  267.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 11, player.y + camera.y + 25), _RGB32(155, 0, 0)
  268.         'right arm
  269.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 11, player.y + camera.y + 25), _RGB32(155, 0, 0)
  270.         'left leg
  271.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 11, player.y + camera.y + 35), _RGB32(155, 0, 0)
  272.         'right leg
  273.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 11, player.y + camera.y + 35), _RGB32(155, 0, 0)
  274.     END IF
  275.  
  276.     IF t = 2 OR t = 6 THEN
  277.         'left arm
  278.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 9, player.y + camera.y + 24), _RGB32(155, 0, 0)
  279.         'right arm
  280.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 9, player.y + camera.y + 24), _RGB32(155, 0, 0)
  281.         'left leg
  282.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 9, player.y + camera.y + 35), _RGB32(155, 0, 0)
  283.         'right leg
  284.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 9, player.y + camera.y + 35), _RGB32(155, 0, 0)
  285.     END IF
  286.  
  287.     IF t = 3 OR t = 5 THEN
  288.         'left arm
  289.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 7, player.y + camera.y + 24), _RGB32(155, 0, 0)
  290.         'right arm
  291.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 7, player.y + camera.y + 24), _RGB32(155, 0, 0)
  292.         'left leg
  293.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 7, player.y + camera.y + 35), _RGB32(155, 0, 0)
  294.         'right leg
  295.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 7, player.y + camera.y + 35), _RGB32(155, 0, 0)
  296.     END IF
  297.  
  298.     IF t = 4 THEN
  299.         'left arm
  300.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 5, player.y + camera.y + 23), _RGB32(155, 0, 0)
  301.         'right arm
  302.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 5, player.y + camera.y + 23), _RGB32(155, 0, 0)
  303.         'left leg
  304.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 5, player.y + camera.y + 35), _RGB32(155, 0, 0)
  305.         'right leg
  306.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 5, player.y + camera.y + 35), _RGB32(155, 0, 0)
  307.     END IF
  308.  
  309.     FOR check = -15 TO 15
  310.         IF POINT(player.x + check, player.y + check) = _RGB32(255, 255, 128) THEN
  311.             _DEST map
  312.             FOR sz = .2 TO 35 STEP .2
  313.                 CIRCLE (player.x + check, player.y + check), sz, _RGB32(127, 255, 127)
  314.             NEXT sz
  315.             GOSUB findgold:
  316.         END IF
  317.         IF POINT(player.x + check, player.y - check) = _RGB32(255, 255, 128) THEN
  318.             _DEST map
  319.             FOR sz = .2 TO 35 STEP .2
  320.                 CIRCLE (player.x + check, player.y - check), sz, _RGB32(127, 255, 127)
  321.             NEXT sz
  322.             GOSUB findgold:
  323.         END IF
  324.         IF POINT(player.x - check, player.y + check) = _RGB32(255, 255, 128) THEN
  325.             _DEST map
  326.             FOR sz = .2 TO 35 STEP .2
  327.                 CIRCLE (player.x - check, player.y + check), sz, _RGB32(127, 255, 127)
  328.             NEXT sz
  329.             GOSUB findgold:
  330.         END IF
  331.     NEXT check
  332.  
  333.     FOR checkmines = -5 TO 5
  334.         IF POINT(player.x + checkmines, player.y + checkmines) = _RGB32(0, 0, 5) THEN
  335.             _DEST map
  336.             FOR sz = .25 TO 35 STEP .25
  337.                 CIRCLE (player.x + checkmines, player.y + checkmines), sz, _RGB32(127, 127, 127)
  338.             NEXT sz
  339.             FOR sz = 1 TO 35 STEP 5
  340.                 CIRCLE (player.x + checkmines, player.y + checkmines), sz, _RGB32(127, 0, 0)
  341.                 SOUND 150 + (sz * 3), 1
  342.                 _DELAY .05
  343.             NEXT sz
  344.             player.x = INT(_WIDTH(map) * RND)
  345.             player.y = INT(_HEIGHT(map) * RND)
  346.             score$ = STR$(score)
  347.             level$ = STR$(level)
  348.             coordx$ = STR$(player.x)
  349.             coordy$ = STR$(player.y)
  350.             _TITLE "Level: " + level$ + "   Score: " + score$ + "                         Coordinates: " + coordx$ + "," + coordy$
  351.             _DEST 0
  352.             GOTO nex:
  353.         END IF
  354.         IF POINT(player.x + checkmines, player.y - checkmines) = _RGB32(0, 0, 5) THEN
  355.             _DEST map
  356.             FOR sz = .25 TO 35 STEP .25
  357.                 CIRCLE (player.x + checkmines, player.y - checkmines), sz, _RGB32(127, 127, 127)
  358.             NEXT sz
  359.             FOR sz = 1 TO 35 STEP 5
  360.                 CIRCLE (player.x + checkmines, player.y - checkmines), sz, _RGB32(127, 0, 0)
  361.                 SOUND 150 + (sz * 3), 1
  362.                 _DELAY .05
  363.             NEXT sz
  364.             player.x = INT(_WIDTH(map) * RND)
  365.             player.y = INT(_HEIGHT(map) * RND)
  366.             score$ = STR$(score)
  367.             level$ = STR$(level)
  368.             coordx$ = STR$(player.x)
  369.             coordy$ = STR$(player.y)
  370.             _TITLE "Level: " + level$ + "   Score: " + score$ + "                         Coordinates: " + coordx$ + "," + coordy$
  371.             _DEST 0
  372.             GOTO nex:
  373.         END IF
  374.         IF POINT(player.x - checkmines, player.y + checkmines) = _RGB32(0, 0, 5) THEN
  375.             _DEST map
  376.             FOR sz = .25 TO 35 STEP .25
  377.                 CIRCLE (player.x - checkmines, player.y + checkmines), sz, _RGB32(127, 127, 127)
  378.             NEXT sz
  379.             FOR sz = 1 TO 35 STEP 5
  380.                 CIRCLE (player.x - checkmines, player.y + checkmines), sz, _RGB32(127, 0, 0)
  381.                 SOUND 150 + (sz * 3), 1
  382.                 _DELAY .05
  383.             NEXT sz
  384.             player.x = INT(_WIDTH(map) * RND)
  385.             player.y = INT(_HEIGHT(map) * RND)
  386.             score$ = STR$(score)
  387.             level$ = STR$(level)
  388.             coordx$ = STR$(player.x)
  389.             coordy$ = STR$(player.y)
  390.             _TITLE "Level: " + level$ + "   Score: " + score$ + "                         Coordinates: " + coordx$ + "," + coordy$
  391.             _DEST 0
  392.             GOTO nex:
  393.         END IF
  394.     NEXT checkmines
  395.     nex:
  396.  
  397.     'Map
  398.     radarx1 = (_WIDTH + 735) - _WIDTH
  399.     radary1 = (_HEIGHT + 535) - _HEIGHT
  400.     radarx2 = (_WIDTH + 785) - _WIDTH
  401.     radary2 = (_HEIGHT + 585) - _HEIGHT
  402.     LINE (radarx1, radary1)-(radarx2, radary2), _RGB32(0, 0, 0), BF
  403.     xradar = player.x / 112: yradar = player.y / 84
  404.     FOR sz = .25 TO 2 STEP .25
  405.         CIRCLE ((radarx1 + xradar), (radary1 + yradar)), sz, _RGB32(255, 0, 0)
  406.     NEXT sz
  407.     FOR gold2 = 1 TO 25
  408.         xgold = goldx(gold2) / 112: ygold = goldy(gold2) / 84
  409.         FOR sz = .25 TO 1 STEP .25
  410.             CIRCLE ((radarx1 + xgold), (radary1 + ygold)), sz, _RGB32(255, 255, 0)
  411.         NEXT sz
  412.     NEXT gold2
  413.  
  414.     _DISPLAY
  415.     _LIMIT 60
  416.  
  417. findgold:
  418. FOR snd = 400 TO 800 STEP 100
  419.     SOUND snd, .5
  420. NEXT snd
  421. score = score + 100
  422. score$ = STR$(score)
  423. level$ = STR$(level)
  424. coordx$ = STR$(player.x)
  425. coordy$ = STR$(player.y)
  426. _TITLE "Level: " + level$ + "   Score: " + score$ + "                         Coordinates: " + coordx$ + "," + coordy$
  427. IF score / 2000 = INT(score / 2000) THEN
  428.     level = level + 1
  429.     minelevel = minelevel + 50
  430.     level$ = STR$(level)
  431.     coordx$ = STR$(player.x)
  432.     coordy$ = STR$(player.y)
  433.     _TITLE "Level: " + level$ + "   Score: " + score$ + "                         Coordinates: " + coordx$ + "," + coordy$
  434.     IF level = 11 THEN GOTO win:
  435.     GOTO start2:
  436.  
  437. done:
  438. LOCATE 10, 45: PRINT "G A M E     O V E R"
  439. FOR snd = 450 TO 150 STEP -25
  440.     SOUND snd, .5
  441. NEXT snd
  442. LOCATE 13, 45: PRINT "Again (Y/N)?"
  443. ag:
  444. ag$ = INKEY$
  445. IF ag$ = "y" OR ag$ = "Y" THEN GOTO start:
  446. IF ag$ = "n" OR ag$ = "N" THEN END
  447. GOTO ag:
  448.  
  449. win:
  450. level = 10
  451. level$ = STR$(level)
  452. _TITLE "Level: " + level$ + "   Score: " + score$ + "                         Coordinates: " + coordx$ + "," + coordy$
  453. LOCATE 10, 45: PRINT "G A M E     W O N ! ! ! ! ! ! !"
  454. FOR snd = 450 TO 150 STEP -25
  455.     SOUND snd, .5
  456. NEXT snd
  457. LOCATE 13, 45: PRINT "Again (Y/N)?"
  458. ag2:
  459. ag$ = INKEY$
  460. IF ag$ = "y" OR ag$ = "Y" THEN GOTO start:
  461. IF ag$ = "n" OR ag$ = "N" THEN END
  462. GOTO ag2:
  463.  
  464. 'Thanks to FelippeHeitor for this Sub and the camera code above.
  465. SUB adjustCamera
  466.     IF player.x + camera.x > _WIDTH / 2 OR player.x + camera.x < _WIDTH / 2 THEN
  467.         camera.x = _WIDTH / 2 - player.x
  468.     END IF
  469.     IF camera.x > 0 THEN camera.x = 0
  470.     IF camera.x < -(_WIDTH(map) - _WIDTH) THEN camera.x = -(_WIDTH(map) - _WIDTH)
  471.  
  472.     IF player.y + camera.y > _HEIGHT / 2 OR player.y + camera.y < _HEIGHT / 2 THEN
  473.         camera.y = _HEIGHT / 2 - player.y
  474.     END IF
  475.     IF camera.y > 0 THEN camera.y = 0
  476.     IF camera.y < -(_HEIGHT(map) - _HEIGHT) THEN camera.y = -(_HEIGHT(map) - _HEIGHT)
  477.  





Title: Re: Find The Gold!
Post by: bplus on October 27, 2020, 06:20:52 pm
Oh nice you did get a little thumbnail!  What are the target like things?

You know what I need is a countdown of how many gold bars are left. No rest for the wicked. ;-))
Title: Re: Find The Gold!
Post by: SierraKen on October 27, 2020, 06:22:14 pm
LOL I thought about that but I am just so used to counting them with the Score amount. 100 per gold bar. Every 2000 passes a level. But I'll add it. LOL
Title: Re: Find The Gold!
Post by: SierraKen on October 27, 2020, 06:23:26 pm
The target-like things? Do you mean the yellow dots in the map? That's where the gold is. You are the red one.
Title: Re: Find The Gold!
Post by: bplus on October 27, 2020, 06:23:52 pm
LOL I thought about that but I am just so used to counting them with the Score amount. 100 per gold bar. Every 2000 passes a level. But I'll add it. LOL

OH OK that is good, go rest :-))
Title: Re: Find The Gold!
Post by: bplus on October 27, 2020, 06:26:15 pm
The target-like things? Do you mean the yellow dots in the map? That's where the gold is. You are the red one.

No this:

  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Find The Gold!
Post by: SierraKen on October 27, 2020, 06:42:19 pm
LOL nah I just added the countdown. :)) Here you go:

Code: QB64: [Select]
  1. 'Find the Gold! by SierraKen
  2. 'October 27, 2020
  3. 'Thanks for the great mapping code by FellipeHeitor and help from B+ and ideas from Aurel!
  4. 'Newest Additions: Mine Shafts and Music.
  5. 'Music created by me many years ago.
  6. 'Added random houses on each level.
  7. 'Added 5 extra gold bars on each level.
  8. 'Added Map in lower right corner.
  9. 'Added countdown of gold bars per level.
  10.  
  11. SCREEN _NEWIMAGE(800, 600, 32)
  12.  
  13. TYPE object
  14.     x AS SINGLE
  15.     y AS SINGLE
  16.  
  17. DIM SHARED player AS object
  18. DIM SHARED camera AS object
  19. DIM playerSpeed AS SINGLE
  20. DIM minelevel AS SINGLE
  21. DIM level AS SINGLE
  22. DIM score AS SINGLE
  23. DIM leveltime AS SINGLE
  24. DIM gametime AS SINGLE
  25. DIM seconds AS SINGLE
  26. DIM goldx(50), goldy(50)
  27.  
  28. _TITLE "Loading....."
  29. s& = _SNDOPEN("Hello_Martian_Home.mp3")
  30. start:
  31. minelevel = 50
  32. score = 0
  33. level = 1
  34. gbars = 20
  35. gbars$ = STR$(gbars)
  36. start2:
  37. player.x = _WIDTH / 2
  38. player.y = _HEIGHT / 2
  39.  
  40. map = _NEWIMAGE(_WIDTH * 7, _HEIGHT * 7, 32)
  41.  
  42. _DEST map
  43.  
  44. CLS , _RGB32(0, 200, 0)
  45. _LIMIT 2000
  46.  
  47. 'Lakes
  48. FOR lakes = 1 TO 100
  49.     w = RND
  50.     h = RND
  51.     sze = (RND * 250) + 100
  52.     shape = RND
  53.     FOR sz = .25 TO sze STEP .25
  54.         CIRCLE (w * _WIDTH, h * _HEIGHT), sz, _RGB32(0, 128, 255), , , shape
  55.     NEXT sz
  56. NEXT lakes
  57.  
  58. 'Hills
  59. FOR hills = 1 TO 1200
  60.     xx = (RND * _WIDTH)
  61.     sz = INT(RND * 100) + 200
  62.     shape = RND
  63.     hillcolors:
  64.     blue = blue + .05
  65.     c3 = INT(RND * 50) + 20 + blue
  66.     c2 = c3 * 2
  67.     c1 = c3 * 3
  68.     IF c1 = 255 AND c2 = 255 AND c3 = 128 THEN GOTO hillcolors:
  69.     yy = yy + 4
  70.     FOR hill = 1 TO sz STEP .25
  71.         hh = hh + .025
  72.         IF hh > 100 THEN hh = 100
  73.         cc1 = c1 + hh
  74.         cc2 = c2 + hh
  75.         cc3 = c3 + hh
  76.         CIRCLE (xx, yy), hill, _RGB32(cc1, cc2, cc3), 2 * _PI, _PI, shape
  77.     NEXT hill
  78.     hh = 0
  79. NEXT hills
  80. blue = 0
  81. yy = 0
  82.  
  83. 'Trees
  84. FOR trees = 1 TO 1000
  85.     tx = RND
  86.     tx = tx * _WIDTH
  87.     ty = RND
  88.     ty = ty * _HEIGHT
  89.     tsz = (RND * 40) + 10
  90.     LINE (tx, ty)-(tx, ty + tsz + 5), _RGB32(188, 127, 127)
  91.     FOR branches = ty TO ty + tsz STEP 3
  92.         trim = trim + 2
  93.         LINE (tx, branches)-(tx - trim, branches + 5), _RGB32(0, 183, 127)
  94.         LINE (tx, branches)-(tx + trim, branches + 5), _RGB32(0, 183, 127)
  95.     NEXT branches
  96.     trim = 0
  97. NEXT trees
  98.  
  99. 'Mine Shafts
  100. FOR mines = 1 TO minelevel
  101.     mines:
  102.     bx = RND
  103.     bx = bx * _WIDTH
  104.     by = RND
  105.     by = by * _HEIGHT
  106.     IF bx < 500 AND by < 400 THEN GOTO mines:
  107.     FOR sz = .25 TO 10 STEP .25
  108.         CIRCLE (bx, by), sz, _RGB32(0, 0, 5)
  109.     NEXT sz
  110. NEXT mines
  111.  
  112. 'Houses
  113. FOR houses = 1 TO 10
  114.     xhouse = INT(RND * _WIDTH)
  115.     yhouse = INT(RND * _HEIGHT)
  116.     szhouse = INT(RND * 60) + 30
  117.     LINE (xhouse, yhouse)-(xhouse + szhouse, yhouse + szhouse), _RGB32(183, 161, 150), BF
  118.     'roof
  119.     FOR sz = .25 TO (szhouse / 2) STEP .25
  120.         CIRCLE (xhouse + (szhouse / 2), yhouse), sz, _RGB32(150, 105, 105), _PI * 2, _PI, .5
  121.     NEXT sz
  122.     'door
  123.     LINE (xhouse + (szhouse / 2) - szhouse * .1, yhouse + szhouse - 15)-(xhouse + (szhouse / 2) + szhouse * .1, yhouse + szhouse), _RGB32(150, 105, 105), BF
  124.     'windows
  125.     LINE (xhouse + szhouse * .2, yhouse + szhouse * .2)-(xhouse + szhouse * .4, yhouse + szhouse * .4), _RGB32(150, 105, 105), BF
  126.     LINE (xhouse + szhouse * .6, yhouse + szhouse * .2)-(xhouse + szhouse * .8, yhouse + szhouse * .4), _RGB32(150, 105, 105), BF
  127. NEXT houses
  128.  
  129.  
  130. 'Place Gold
  131. FOR gold = 1 TO 25
  132.     gold:
  133.     w2 = INT(RND * _WIDTH) - 40
  134.     h2 = INT(RND * _HEIGHT) - 40
  135.     goldx(gold) = w2
  136.     goldy(gold) = h2
  137.     IF w2 < 40 THEN w2 = 40
  138.     IF h2 < 40 THEN h2 = 40
  139.     IF h2 > (_HEIGHT - 150) THEN GOTO gold:
  140.     IF POINT(w2, h2) = _RGB32(255, 255, 128) THEN GOTO gold:
  141.     IF POINT(w2, h2) = _RGB32(0, 0, 0) THEN GOTO gold:
  142.     IF POINT(w2, h2) = _RGB32(0, 0, 5) THEN GOTO gold:
  143.     FOR check = -10 TO 10
  144.         IF POINT(w2 + check, h2 + check) = _RGB32(183, 161, 150) THEN GOTO gold:
  145.         IF POINT(w2 + check, h2 + check) = _RGB32(150, 105, 105) THEN GOTO gold:
  146.     NEXT check
  147.     'Gold
  148.     COLOR _RGB32(0, 0, 0), _RGB32(255, 255, 128)
  149.     _PRINTSTRING (w2, h2), "GOLD"
  150. NEXT gold
  151.  
  152.  
  153.  
  154. IF level > 1 THEN GOTO begin:
  155.  
  156. playerSpeed = 8
  157.  
  158. CONST keyUP = 18432
  159. CONST keyDOWN = 20480
  160. CONST keyLEFT = 19200
  161. CONST keyRIGHT = 19712
  162. CONST keyESC = 27
  163. _PUTIMAGE (camera.x, camera.y), map
  164.  
  165. LOCATE 3, 22: PRINT "Use the arrow keys (or WASD keys) to find 20 gold bars per level."
  166. LOCATE 4, 22: PRINT "To make it a little easier, there are 25 gold bars on each level."
  167. LOCATE 5, 22: PRINT "Every level will have a shorter time."
  168. LOCATE 6, 22: PRINT "After Level 10 you win the game."
  169. LOCATE 7, 22: PRINT "Be careful not to step in the black mine shafts or they will send"
  170. LOCATE 8, 22: PRINT "you to a random location."
  171. LOCATE 9, 22: PRINT "Every level will have more mine shafts."
  172. LOCATE 10, 22: PRINT "Use the Map in the lower right corner to see where the gold is placed."
  173. LOCATE 11, 22: PRINT "Map will not remove gold dot after you have picked it up."
  174. LOCATE 12, 22: PRINT "You show up on the map as a red dot."
  175. LOCATE 14, 22: PRINT "Game and Music created by SierraKen."
  176. LOCATE 17, 32: PRINT "* Press Any Key To Begin. *"
  177. _TITLE "Find The Gold!"
  178. pause:
  179. a$ = INKEY$
  180. IF a$ <> "" THEN GOTO begin:
  181. GOTO pause:
  182.  
  183. begin:
  184. score$ = STR$(score)
  185. level$ = STR$(level)
  186. _TITLE "Level: " + level$ + "   Score: " + score$
  187. seconds = INT(TIMER)
  188.     CLS
  189.     leveltime = level * 10
  190.     gametime = (410 - leveltime) - (INT(TIMER) - seconds)
  191.     _PUTIMAGE (camera.x, camera.y), map
  192.     LOCATE 1, 1: PRINT "Time Left: "; gametime
  193.     IF gametime < 1 THEN GOTO done:
  194.     IF _KEYDOWN(keyUP) OR _KEYDOWN(119) THEN
  195.         player.y = player.y - playerSpeed
  196.         t = t + 1
  197.         score$ = STR$(score)
  198.         level$ = STR$(level)
  199.         coordx$ = STR$(player.x)
  200.         coordy$ = STR$(player.y)
  201.         _TITLE "Level: " + level$ + "   Score: " + score$ + "                         Coordinates: " + coordx$ + "," + coordy$ + "                    Gold Bars Left To Get: " + gbars$
  202.     END IF
  203.     IF _KEYDOWN(keyDOWN) OR _KEYDOWN(115) THEN
  204.         player.y = player.y + playerSpeed
  205.         t = t + 1
  206.         score$ = STR$(score)
  207.         level$ = STR$(level)
  208.         coordx$ = STR$(player.x)
  209.         coordy$ = STR$(player.y)
  210.         _TITLE "Level: " + level$ + "   Score: " + score$ + "                         Coordinates: " + coordx$ + "," + coordy$ + "                    Gold Bars Left To Get: " + gbars$
  211.     END IF
  212.     IF _KEYDOWN(keyLEFT) OR _KEYDOWN(97) THEN
  213.         player.x = player.x - playerSpeed
  214.         t = t + 1
  215.         score$ = STR$(score)
  216.         level$ = STR$(level)
  217.         coordx$ = STR$(player.x)
  218.         coordy$ = STR$(player.y)
  219.         _TITLE "Level: " + level$ + "   Score: " + score$ + "                         Coordinates: " + coordx$ + "," + coordy$ + "                    Gold Bars Left To Get: " + gbars$
  220.     END IF
  221.     IF _KEYDOWN(keyRIGHT) OR _KEYDOWN(100) THEN
  222.         player.x = player.x + playerSpeed
  223.         t = t + 1
  224.         score$ = STR$(score)
  225.         level$ = STR$(level)
  226.         coordx$ = STR$(player.x)
  227.         coordy$ = STR$(player.y)
  228.         _TITLE "Level: " + level$ + "   Score: " + score$ + "                         Coordinates: " + coordx$ + "," + coordy$ + "                    Gold Bars Left To Get: " + gbars$
  229.     END IF
  230.     IF _KEYDOWN(keyESC) THEN END
  231.     IF player.x < 0 THEN player.x = 0
  232.     IF player.x > _WIDTH(map) THEN player.x = _WIDTH(map)
  233.     IF player.y < 0 THEN player.y = 0
  234.     IF player.y > _HEIGHT(map) THEN player.y = _HEIGHT(map)
  235.  
  236.     adjustCamera
  237.  
  238.     'Draw Head
  239.     FOR sz = .25 TO 10 STEP .25
  240.         CIRCLE (player.x + camera.x, player.y + camera.y), sz, _RGB32(255, 166, 127)
  241.     NEXT sz
  242.     'Draw Smile
  243.     CIRCLE (player.x + camera.x, player.y + camera.y + 2), 7, _RGB32(255, 0, 0), _PI, 2 * _PI, .5
  244.     'Draw Eyes
  245.     CIRCLE (player.x + camera.x - 4, player.y + camera.y - 2), 1, _RGB32(0, 0, 255)
  246.     CIRCLE (player.x + camera.x + 4, player.y + camera.y - 2), 1, _RGB32(0, 0, 255)
  247.     'hat
  248.     LINE (player.x + camera.x - 10, player.y + camera.y - 10)-(player.x + camera.x + 10, player.y + camera.y - 9), _RGB32(155, 0, 0), BF
  249.     LINE (player.x + camera.x - 5, player.y + camera.y - 9)-(player.x + camera.x + 5, player.y + camera.y - 15), _RGB32(155, 0, 0), BF
  250.     'body
  251.     LINE (player.x + camera.x, player.y + camera.y + 10)-(player.x + camera.x, player.y + camera.y + 20), _RGB32(155, 0, 0)
  252.  
  253.     IF t > 7 THEN t = 0
  254.  
  255.     'rest of body
  256.     IF t = 0 THEN
  257.         'left arm
  258.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 15, player.y + camera.y + 25), _RGB32(155, 0, 0)
  259.         'right arm
  260.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 15, player.y + camera.y + 25), _RGB32(155, 0, 0)
  261.         'left leg
  262.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 15, player.y + camera.y + 35), _RGB32(155, 0, 0)
  263.         'right leg
  264.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 15, player.y + camera.y + 35), _RGB32(155, 0, 0)
  265.     END IF
  266.  
  267.     IF t = 1 OR t = 7 THEN
  268.         'left arm
  269.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 11, player.y + camera.y + 25), _RGB32(155, 0, 0)
  270.         'right arm
  271.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 11, player.y + camera.y + 25), _RGB32(155, 0, 0)
  272.         'left leg
  273.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 11, player.y + camera.y + 35), _RGB32(155, 0, 0)
  274.         'right leg
  275.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 11, player.y + camera.y + 35), _RGB32(155, 0, 0)
  276.     END IF
  277.  
  278.     IF t = 2 OR t = 6 THEN
  279.         'left arm
  280.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 9, player.y + camera.y + 24), _RGB32(155, 0, 0)
  281.         'right arm
  282.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 9, player.y + camera.y + 24), _RGB32(155, 0, 0)
  283.         'left leg
  284.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 9, player.y + camera.y + 35), _RGB32(155, 0, 0)
  285.         'right leg
  286.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 9, player.y + camera.y + 35), _RGB32(155, 0, 0)
  287.     END IF
  288.  
  289.     IF t = 3 OR t = 5 THEN
  290.         'left arm
  291.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 7, player.y + camera.y + 24), _RGB32(155, 0, 0)
  292.         'right arm
  293.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 7, player.y + camera.y + 24), _RGB32(155, 0, 0)
  294.         'left leg
  295.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 7, player.y + camera.y + 35), _RGB32(155, 0, 0)
  296.         'right leg
  297.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 7, player.y + camera.y + 35), _RGB32(155, 0, 0)
  298.     END IF
  299.  
  300.     IF t = 4 THEN
  301.         'left arm
  302.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x - 5, player.y + camera.y + 23), _RGB32(155, 0, 0)
  303.         'right arm
  304.         LINE (player.x + camera.x, player.y + camera.y + 13)-(player.x + camera.x + 5, player.y + camera.y + 23), _RGB32(155, 0, 0)
  305.         'left leg
  306.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x - 5, player.y + camera.y + 35), _RGB32(155, 0, 0)
  307.         'right leg
  308.         LINE (player.x + camera.x, player.y + camera.y + 20)-(player.x + camera.x + 5, player.y + camera.y + 35), _RGB32(155, 0, 0)
  309.     END IF
  310.  
  311.     FOR check = -15 TO 15
  312.         IF POINT(player.x + check, player.y + check) = _RGB32(255, 255, 128) THEN
  313.             _DEST map
  314.             FOR sz = .2 TO 35 STEP .2
  315.                 CIRCLE (player.x + check, player.y + check), sz, _RGB32(127, 255, 127)
  316.             NEXT sz
  317.             GOSUB findgold:
  318.         END IF
  319.         IF POINT(player.x + check, player.y - check) = _RGB32(255, 255, 128) THEN
  320.             _DEST map
  321.             FOR sz = .2 TO 35 STEP .2
  322.                 CIRCLE (player.x + check, player.y - check), sz, _RGB32(127, 255, 127)
  323.             NEXT sz
  324.             GOSUB findgold:
  325.         END IF
  326.         IF POINT(player.x - check, player.y + check) = _RGB32(255, 255, 128) THEN
  327.             _DEST map
  328.             FOR sz = .2 TO 35 STEP .2
  329.                 CIRCLE (player.x - check, player.y + check), sz, _RGB32(127, 255, 127)
  330.             NEXT sz
  331.             GOSUB findgold:
  332.         END IF
  333.     NEXT check
  334.  
  335.     FOR checkmines = -5 TO 5
  336.         IF POINT(player.x + checkmines, player.y + checkmines) = _RGB32(0, 0, 5) THEN
  337.             _DEST map
  338.             FOR sz = .25 TO 35 STEP .25
  339.                 CIRCLE (player.x + checkmines, player.y + checkmines), sz, _RGB32(127, 127, 127)
  340.             NEXT sz
  341.             FOR sz = 1 TO 35 STEP 5
  342.                 CIRCLE (player.x + checkmines, player.y + checkmines), sz, _RGB32(127, 0, 0)
  343.                 SOUND 150 + (sz * 3), 1
  344.                 _DELAY .05
  345.             NEXT sz
  346.             player.x = INT(_WIDTH(map) * RND)
  347.             player.y = INT(_HEIGHT(map) * RND)
  348.             score$ = STR$(score)
  349.             level$ = STR$(level)
  350.             coordx$ = STR$(player.x)
  351.             coordy$ = STR$(player.y)
  352.             _TITLE "Level: " + level$ + "   Score: " + score$ + "                         Coordinates: " + coordx$ + "," + coordy$ + "                   Gold Bars Left To Get: " + gbars$
  353.             _DEST 0
  354.             GOTO nex:
  355.         END IF
  356.         IF POINT(player.x + checkmines, player.y - checkmines) = _RGB32(0, 0, 5) THEN
  357.             _DEST map
  358.             FOR sz = .25 TO 35 STEP .25
  359.                 CIRCLE (player.x + checkmines, player.y - checkmines), sz, _RGB32(127, 127, 127)
  360.             NEXT sz
  361.             FOR sz = 1 TO 35 STEP 5
  362.                 CIRCLE (player.x + checkmines, player.y - checkmines), sz, _RGB32(127, 0, 0)
  363.                 SOUND 150 + (sz * 3), 1
  364.                 _DELAY .05
  365.             NEXT sz
  366.             player.x = INT(_WIDTH(map) * RND)
  367.             player.y = INT(_HEIGHT(map) * RND)
  368.             score$ = STR$(score)
  369.             level$ = STR$(level)
  370.             coordx$ = STR$(player.x)
  371.             coordy$ = STR$(player.y)
  372.             _TITLE "Level: " + level$ + "   Score: " + score$ + "                         Coordinates: " + coordx$ + "," + coordy$ + "                    Gold Bars Left To Get: " + gbars$
  373.             _DEST 0
  374.             GOTO nex:
  375.         END IF
  376.         IF POINT(player.x - checkmines, player.y + checkmines) = _RGB32(0, 0, 5) THEN
  377.             _DEST map
  378.             FOR sz = .25 TO 35 STEP .25
  379.                 CIRCLE (player.x - checkmines, player.y + checkmines), sz, _RGB32(127, 127, 127)
  380.             NEXT sz
  381.             FOR sz = 1 TO 35 STEP 5
  382.                 CIRCLE (player.x - checkmines, player.y + checkmines), sz, _RGB32(127, 0, 0)
  383.                 SOUND 150 + (sz * 3), 1
  384.                 _DELAY .05
  385.             NEXT sz
  386.             player.x = INT(_WIDTH(map) * RND)
  387.             player.y = INT(_HEIGHT(map) * RND)
  388.             score$ = STR$(score)
  389.             level$ = STR$(level)
  390.             coordx$ = STR$(player.x)
  391.             coordy$ = STR$(player.y)
  392.             _TITLE "Level: " + level$ + "   Score: " + score$ + "                         Coordinates: " + coordx$ + "," + coordy$ + "                    Gold Bars Left To Get: " + gbars$
  393.             _DEST 0
  394.             GOTO nex:
  395.         END IF
  396.     NEXT checkmines
  397.     nex:
  398.  
  399.     'Map
  400.     radarx1 = (_WIDTH + 735) - _WIDTH
  401.     radary1 = (_HEIGHT + 535) - _HEIGHT
  402.     radarx2 = (_WIDTH + 785) - _WIDTH
  403.     radary2 = (_HEIGHT + 585) - _HEIGHT
  404.     LINE (radarx1, radary1)-(radarx2, radary2), _RGB32(0, 0, 0), BF
  405.     xradar = player.x / 112: yradar = player.y / 84
  406.     FOR sz = .25 TO 2 STEP .25
  407.         CIRCLE ((radarx1 + xradar), (radary1 + yradar)), sz, _RGB32(255, 0, 0)
  408.     NEXT sz
  409.     FOR gold2 = 1 TO 25
  410.         xgold = goldx(gold2) / 112: ygold = goldy(gold2) / 84
  411.         FOR sz = .25 TO 1 STEP .25
  412.             CIRCLE ((radarx1 + xgold), (radary1 + ygold)), sz, _RGB32(255, 255, 0)
  413.         NEXT sz
  414.     NEXT gold2
  415.  
  416.     _DISPLAY
  417.     _LIMIT 60
  418.  
  419. findgold:
  420. FOR snd = 400 TO 800 STEP 100
  421.     SOUND snd, .5
  422. NEXT snd
  423. score = score + 100
  424. score$ = STR$(score)
  425. level$ = STR$(level)
  426. coordx$ = STR$(player.x)
  427. coordy$ = STR$(player.y)
  428. gbars = gbars - 1
  429. gbars$ = STR$(gbars)
  430. _TITLE "Level: " + level$ + "   Score: " + score$ + "                         Coordinates: " + coordx$ + "," + coordy$ + "                    Gold Bars Left To Get: " + gbars$
  431. IF score / 2000 = INT(score / 2000) THEN
  432.     level = level + 1
  433.     minelevel = minelevel + 50
  434.     level$ = STR$(level)
  435.     coordx$ = STR$(player.x)
  436.     coordy$ = STR$(player.y)
  437.     _TITLE "Level: " + level$ + "   Score: " + score$ + "                         Coordinates: " + coordx$ + "," + coordy$ + "                    Gold Bars Left To Get: " + gbars$
  438.     IF level = 11 THEN GOTO win:
  439.     gbars = 20
  440.     gbars$ = STR$(gbars)
  441.     GOTO start2:
  442.  
  443. done:
  444. LOCATE 10, 45: PRINT "G A M E     O V E R"
  445. FOR snd = 450 TO 150 STEP -25
  446.     SOUND snd, .5
  447. NEXT snd
  448. LOCATE 13, 45: PRINT "Again (Y/N)?"
  449. ag:
  450. ag$ = INKEY$
  451. IF ag$ = "y" OR ag$ = "Y" THEN GOTO start:
  452. IF ag$ = "n" OR ag$ = "N" THEN END
  453. GOTO ag:
  454.  
  455. win:
  456. level = 10
  457. level$ = STR$(level)
  458. _TITLE "Level: " + level$ + "   Score: " + score$ + "                         Coordinates: " + coordx$ + "," + coordy$
  459. LOCATE 10, 45: PRINT "G A M E     W O N ! ! ! ! ! ! !"
  460. FOR snd = 450 TO 150 STEP -25
  461.     SOUND snd, .5
  462. NEXT snd
  463. LOCATE 13, 45: PRINT "Again (Y/N)?"
  464. ag2:
  465. ag$ = INKEY$
  466. IF ag$ = "y" OR ag$ = "Y" THEN GOTO start:
  467. IF ag$ = "n" OR ag$ = "N" THEN END
  468. GOTO ag2:
  469.  
  470. 'Thanks to FelippeHeitor for this Sub and the camera code above.
  471. SUB adjustCamera
  472.     IF player.x + camera.x > _WIDTH / 2 OR player.x + camera.x < _WIDTH / 2 THEN
  473.         camera.x = _WIDTH / 2 - player.x
  474.     END IF
  475.     IF camera.x > 0 THEN camera.x = 0
  476.     IF camera.x < -(_WIDTH(map) - _WIDTH) THEN camera.x = -(_WIDTH(map) - _WIDTH)
  477.  
  478.     IF player.y + camera.y > _HEIGHT / 2 OR player.y + camera.y < _HEIGHT / 2 THEN
  479.         camera.y = _HEIGHT / 2 - player.y
  480.     END IF
  481.     IF camera.y > 0 THEN camera.y = 0
  482.     IF camera.y < -(_HEIGHT(map) - _HEIGHT) THEN camera.y = -(_HEIGHT(map) - _HEIGHT)
  483.  
Title: Re: Find The Gold!
Post by: SierraKen on October 27, 2020, 06:43:37 pm
Woops sorry (I'm half-with it right now LOL). The grey target looking things is what happens after you have already used a mine shaft. That way you know you have been there before and can't use that mine shaft anymore. :)
Title: Re: Find The Gold!
Post by: SierraKen on October 28, 2020, 03:24:29 pm
I finally won the game. :) It's not hard now with the mini-map. :)