Author Topic: Search-Man Game  (Read 7507 times)

0 Members and 1 Guest are viewing this topic.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Search-Man Game
« on: August 28, 2019, 08:26:57 pm »
After working incredibly hard on this game, I have come to a point where I just don't know any more programming to make it better. But I think it's still a cute game to play. Search-Man is a little bit like Pac-Man but the mazes are much more complex and different every level. They also change colors. You eat round orange candy (like pellets in Pac-Man) all through the maze. Every level also has different sizes of hallways, so some mazes are much harder than others. The size of your guy depends on the width of the hallways on that specific level.  You move around a guy that chomps down on them. You see his white teeth when you eat one. You control with the arrow keys. The game is also a lot more random than Pac-Man in that you don't get chased by ghosts or anything, instead 4 random bombs appear in random places on the screen. If you touch one you explode. I experimented with making it a little easier to have them slowly appear to give you time to get away, but it was kinda hard and also the more I think about it, the game would just get a lot more easier and less exciting. To make the bombs go away for 20 seconds, you need to find a rectangular lever, which there are 5 or so scattered around. You get to the next level when a certain amount of points have been made. I tried to make it so you have to get all the candy, but either I had candy directly under other candy, or it was detecting the same one before it disappeared more than once. I might look more into that. But I can't promise anything. You start out with 3 players. The splash screen shows your guy up close for a few seconds. Oh and please don't be overly critical, it took me around 30 hours total to make this game and it's the best maze-type game I've ever made. But also don't expect too much. :) Enjoy.
Oh also, there are times when your guy explodes when you don't see any bombs, I believe that is when the bombs are about to appear but haven't yet and your guy is there first. I am also looking into that somewhat.
Code: QB64: [Select]
  1. _TITLE "Search-Man"
  2. SCREEN _NEWIMAGE(800, 600, 32)
  3. _LIMIT 3000
  4. xx = 350: yy = 300: h = 200
  5. splashscreen:
  6. LINE (xx, yy)-(xx + INT(h / 3), yy + INT(h / 3)), _RGB32(0, 255, 0), BF
  7. LINE (xx, yy)-(xx + INT(h / 3), yy + 3), _RGB32(139, 116, 105), BF
  8. ex1 = (xx + (INT(h / 3) / 2) / 2)
  9. ex2 = (xx + (INT(h / 3) / 2) / .65)
  10. ey = (yy + (INT(h / 3) / 2) / 2)
  11. mx = (xx + (INT(h / 3) / 2))
  12. my = (yy + (INT(h / 2.2) / 2))
  13. ny = (yy + (h / 2.85) / 2)
  14. FOR sz = .25 TO 2 STEP .25
  15.     CIRCLE (ex1, ey), sz, _RGB32(0, 127, 255)
  16.     CIRCLE (ex2, ey), sz, _RGB32(0, 127, 255)
  17. NEXT sz
  18. FOR sz = .25 TO 2.5 STEP .25
  19.     CIRCLE (mx, my), sz, _RGB32(0, 0, 0)
  20. NEXT sz
  21. FOR sz = .25 TO 1.5 STEP .25
  22.     CIRCLE (mx, ny), sz, _RGB32(0, 0, 0)
  23. NEXT sz
  24. mouth:
  25. m = m + 1
  26. IF m > 9 THEN GOTO begin:
  27. IF m = 1 THEN mouth = 0
  28. IF m = 2 THEN mouth = 1
  29. IF m = 3 THEN mouth = 0
  30. IF m = 4 THEN mouth = 1
  31. IF m = 5 THEN mouth = 0
  32. IF m = 6 THEN mouth = 1
  33. IF m = 7 THEN mouth = 0
  34. IF m = 8 THEN mouth = 1
  35. IF m = 9 THEN mouth = 0
  36. IF mouth = 1 THEN
  37.     FOR sz = .25 TO 2.5 STEP .25
  38.         CIRCLE (mx, my), sz, _RGB32(254, 254, 254)
  39.     NEXT sz
  40. IF mouth = 0 THEN
  41.     FOR sz = .25 TO 1.5 STEP .25
  42.         CIRCLE (mx, my), sz, _RGB32(0, 0, 0)
  43.     NEXT sz
  44. GOTO mouth:
  45. begin:
  46. PRINT "                                     Search-Man"
  47. PRINT "                                     by  Ken G."
  48. PRINT "                - Use the arrow keys to guide your green guy around the maze"
  49. PRINT "                  to eat the orange candy."
  50. PRINT "                - Levels change when a certain amount of points have been reached."
  51. PRINT "                - Avoid hitting the randomly placed red bombs."
  52. PRINT "                - Get the green levers to delete the bombs for 20 seconds."
  53. PRINT "                - You start out with 3 players, Good Luck!"
  54. INPUT "                               Press Enter To Begin.", a$
  55. level = 1
  56. sc = 0
  57. players = 3
  58. level$ = STR$(level)
  59.  
  60. 'Start a new level here.
  61. level:
  62. DIM candyx(500), candyy(500)
  63. DIM leverx(200), levery(200)
  64. x = 400: y = 300
  65. t = 0
  66. c = 0
  67. drx = 0: dry = 0
  68. lv = 0: slv = 0: bombs = 0
  69. lev = 0
  70. mouth = 0
  71. h = INT(RND * 60) + 40
  72.  
  73. 'Randomly choose a wall color.
  74. col = INT(RND * 8) + 1
  75. 'green
  76. IF col = 1 THEN
  77.     col1 = 33: col2 = 230: col3 = 7
  78. 'purple
  79. IF col = 2 THEN
  80.     col1 = 152: col2 = 7: col3 = 230
  81. 'yellow
  82. IF col = 3 THEN
  83.     col1 = 247: col2 = 255: col3 = 8
  84. 'orange
  85. IF col = 4 THEN
  86.     col1 = 255: col2 = 156: col3 = 8
  87. 'red
  88. IF col = 5 THEN
  89.     col1 = 255: col2 = 8: col3 = 8
  90. 'blue
  91. IF col = 6 THEN
  92.     col1 = 8: col2 = 131: col3 = 255
  93. 'white
  94. IF col = 7 THEN
  95.     col1 = 255: col2 = 255: col3 = 255
  96. 'greenish-blue
  97. IF col = 8 THEN
  98.     col1 = 10: col2 = 240: col3 = 201
  99.  
  100. 'Make the walls.
  101.     _LIMIT 3000
  102.     again:
  103.     t = t + 1
  104.     IF t = 30000000 THEN EXIT DO
  105.     oldx = x
  106.     oldy = y
  107.     oldd = d
  108.     d = INT(RND * 4) + 1
  109.     IF d = oldd THEN GOTO again:
  110.     IF d = 1 THEN x = x + h
  111.     IF d = 2 THEN x = x - h
  112.     IF d = 3 THEN y = y + h
  113.     IF d = 4 THEN y = y - h
  114.     IF x > 800 - h OR x < h OR y > 600 - h OR y < h THEN x = 400: y = 300: GOTO again:
  115.     IF POINT(x, y) = _RGB32(col1, col2, col3) THEN GOTO again:
  116.     LINE (oldx, oldy)-(x, y), _RGB32(col1, col2, col3)
  117. t = 0
  118. FOR tt = 1 TO INT(1000 / h)
  119.     x2 = INT(RND * 800) + 1
  120.     y2 = INT(RND * 600) + 1
  121.     d2 = INT(RND * 2) + 1
  122.     IF d2 = 1 THEN LINE (x2, y2)-(x2 + h, y2 + h), _RGB32(0, 0, 0), BF
  123.     IF d2 = 2 THEN LINE (x2, y2)-(x2 + h, y2 + h), _RGB32(0, 0, 0), BF
  124. NEXT tt
  125.  
  126. 'Setup the candy.
  127.     candy:
  128.     candyx = INT(RND * 750) + 25
  129.     candyy = INT(RND * 550) + 25
  130.     FOR cx = -7 TO 7
  131.         FOR cy = -7 TO 7
  132.             IF POINT(candyx + cx, candyy + cy) = _RGB32(col1, col2, col3) THEN GOTO candy:
  133.         NEXT cy
  134.     NEXT cx
  135.     FOR cs = .25 TO 3 STEP .25
  136.         CIRCLE (candyx, candyy), cs, _RGB32(255, 161, 0)
  137.     NEXT cs
  138.     c = c + 1
  139.     candyx(c) = candyx: candyy(c) = candyy
  140.     IF c = 300 THEN EXIT DO
  141.  
  142. 'Setup the levers
  143.     levers:
  144.     leverx = INT(RND * 750) + 25
  145.     levery = INT(RND * 550) + 25
  146.     FOR cx = -2 TO 7
  147.         FOR cy = -2 TO 17
  148.             IF POINT(leverx + cx, levery + cy) = _RGB32(col1, col2, col3) THEN GOTO levers:
  149.         NEXT cy
  150.     NEXT cx
  151.     FOR cx = -5 TO 5
  152.         FOR cy = -5 TO 5
  153.             IF POINT(leverx + cx, levery + cy) = _RGB32(255, 161, 0) THEN GOTO levers:
  154.         NEXT cy
  155.     NEXT cx
  156.     LINE (leverx, levery)-(leverx + 5, levery + 15), _RGB32(22, 255, 122), BF
  157.     lev = lev + 1
  158.     leverx(lev) = leverx: levery(lev) = levery
  159.     IF lev = 5 THEN EXIT DO
  160.  
  161. 'You are coords xx and yy.
  162. xx = 400
  163. yy = 594
  164. _TITLE "Arrow Keys To Move, Esc or Q To Quit."
  165.  
  166. 'The Main Loop
  167.     _LIMIT 3000
  168.     a$ = INKEY$
  169.     IF a$ = CHR$(0) + CHR$(72) THEN
  170.         dry = -1
  171.         drx = 0
  172.     END IF
  173.     IF a$ = CHR$(0) + CHR$(80) THEN
  174.         dry = 1
  175.         drx = 0
  176.     END IF
  177.     IF a$ = CHR$(0) + CHR$(77) THEN
  178.         drx = 1
  179.         dry = 0
  180.     END IF
  181.     IF a$ = CHR$(0) + CHR$(75) THEN
  182.         drx = -1
  183.         dry = 0
  184.     END IF
  185.     IF a$ = CHR$(27) THEN END
  186.     IF a$ = "q" OR a$ = "Q" THEN END
  187.     GOSUB you:
  188.     GOSUB candy2:
  189.     GOSUB lev:
  190.     GOSUB circles:
  191.  
  192. lev:
  193. _LIMIT 3000
  194. FOR wy = -1 TO INT(h / 3) + 15
  195.     FOR wx = -1 TO INT(h / 3) + 5
  196.         IF POINT(xx + wx, yy + wy) = _RGB32(22, 255, 122) THEN
  197.             GOTO deletelever:
  198.         END IF
  199.     NEXT wx
  200. NEXT wy
  201.  
  202. 'Check the area around you to delete the lever.
  203. deletelever:
  204. _LIMIT 3000
  205. FOR wyy = -1 TO INT(h / 3) + 15
  206.     FOR wxx = -1 TO INT(h / 3) + 5
  207.         IF POINT(xx + wxx, yy + wyy) = _RGB32(22, 255, 122) THEN
  208.             FOR cc = 1 TO lev
  209.                 IF xx + wxx = leverx(cc) AND yy + wyy = levery(cc) THEN
  210.                     LINE (leverx(cc), levery(cc))-(leverx(cc) + 5, levery(cc) + 15), _RGB32(0, 0, 0), BF
  211.                     FOR snd = 450 TO 550 STEP 25
  212.                         SOUND snd, .15
  213.                     NEXT snd
  214.                     rr = 0
  215.                     lv = 1
  216.                     oldsecond = TIMER
  217.                 END IF
  218.             NEXT cc
  219.         END IF
  220.     NEXT wxx
  221. NEXT wyy
  222.  
  223. 'The Random Red Bombs
  224. circles:
  225. _LIMIT 3000
  226. IF lv = 1 THEN
  227.     second = TIMER
  228.     IF second - oldsecond > 20 THEN lv = 0: slv = 0: GOTO nexone:
  229.     IF slv = 1 THEN RETURN
  230.     CIRCLE (lx, ly), 15, _RGB32(0, 0, 0)
  231.     CIRCLE (lx2, ly2), 15, _RGB32(0, 0, 0)
  232.     CIRCLE (lx3, ly3), 15, _RGB32(0, 0, 0)
  233.     CIRCLE (lx4, ly4), 15, _RGB32(0, 0, 0)
  234.     slv = 1
  235.     RETURN
  236. nexone:
  237. _LIMIT 3000
  238. IF rr = 1 THEN GOTO skip:
  239. rl = INT(RND * 1000) + 1
  240. IF rl > 975 AND rr = 0 THEN
  241.     lx = INT(RND * 750) + 1
  242.     ly = INT(RND * 500) + 1
  243.     lx2 = INT(RND * 750) + 1
  244.     ly2 = INT(RND * 500) + 1
  245.     lx3 = INT(RND * 750) + 1
  246.     ly3 = INT(RND * 500) + 1
  247.     lx4 = INT(RND * 750) + 1
  248.     ly4 = INT(RND * 500) + 1
  249.     rr = 1
  250. IF rr = 0 THEN RETURN
  251. skip:
  252. _LIMIT 3000
  253. IF bombs = 1 THEN GOTO skip2:
  254. CIRCLE (lx, ly), 15, _RGB32(255, 0, 0)
  255. CIRCLE (lx2, ly2), 15, _RGB32(255, 0, 0)
  256. CIRCLE (lx3, ly3), 15, _RGB32(255, 0, 0)
  257. CIRCLE (lx4, ly4), 15, _RGB32(255, 0, 0)
  258. bombs = 1
  259. skip2:
  260. _LIMIT 3000
  261. IF xx > lx - h / 3 AND xx < lx + h / 3 AND yy > ly - h / 3 AND yy < ly + h / 3 THEN GOSUB KABOOM:
  262. IF xx > lx2 - h / 3 AND xx < lx2 + h / 3 AND yy > ly2 - h / 3 AND yy < ly2 + h / 3 THEN GOSUB KABOOM:
  263. IF xx > lx3 - h / 3 AND xx < lx3 + h / 3 AND yy > ly3 - h / 3 AND yy < ly3 + h / 3 THEN GOSUB KABOOM:
  264. IF xx > lx4 - h / 3 AND xx < lx4 + h / 3 AND yy > ly4 - h / 3 AND yy < ly4 + h / 3 THEN GOSUB KABOOM:
  265. rl2 = INT(RND * 10000) + 1
  266. IF rl2 > 9985 THEN
  267.     rr = 0
  268.     bombs = 0
  269.     CIRCLE (lx, ly), 15, _RGB32(0, 0, 0)
  270.     CIRCLE (lx2, ly2), 15, _RGB32(0, 0, 0)
  271.     CIRCLE (lx3, ly3), 15, _RGB32(0, 0, 0)
  272.     CIRCLE (lx4, ly4), 15, _RGB32(0, 0, 0)
  273.  
  274. KABOOM:
  275. players = players - 1
  276. LINE (xx, yy)-(xx + INT(h / 3), yy + INT(h / 3)), _RGB32(0, 0, 0), BF
  277. CIRCLE (lx, ly), 15, _RGB32(0, 0, 0)
  278. CIRCLE (lx2, ly2), 15, _RGB32(0, 0, 0)
  279. CIRCLE (lx3, ly3), 15, _RGB32(0, 0, 0)
  280. CIRCLE (lx4, ly4), 15, _RGB32(0, 0, 0)
  281. FOR sz = 1 TO 30 STEP 2
  282.     CIRCLE (xx + (h / 3), yy + (h / 3)), sz, _RGB32(255, 0, 0)
  283.     SOUND 100, .25
  284.     _DELAY .1
  285. NEXT sz
  286. FOR sz = 1 TO 30 STEP .25
  287.     CIRCLE (xx + (h / 3), yy + (h / 3)), sz, _RGB32(0, 0, 0)
  288.     _DELAY .01
  289. NEXT sz
  290. xx = 400
  291. yy = 594
  292. rr = 0
  293. players$ = STR$(players)
  294. _TITLE "Score: " + sc$ + "    Players: " + players$ + "   Level: " + level$ + "       Arrow Keys To Move, Esc or Q To Quit."
  295. IF players = 0 THEN
  296.     LOCATE 15, 45: PRINT "G A M E   O V E R"
  297.     LOCATE 17, 45: INPUT "Again(Y/N)"; ag$
  298.     IF LEFT$(ag$, 1) = "y" OR LEFT$(ag$, 1) = "Y" THEN CLEAR: GOTO begin:
  299.     END
  300.  
  301. 'Check to see if you got a candy.
  302. candy2:
  303. _LIMIT 3000
  304. FOR wy = -5 TO INT(h / 3) + 5
  305.     FOR wx = -5 TO INT(h / 3) + 5
  306.         IF POINT(xx + wx, yy + wy) = _RGB32(255, 161, 0) THEN
  307.             sc = sc + 10
  308.             sc$ = STR$(sc)
  309.             players$ = STR$(players)
  310.             _TITLE "Score: " + sc$ + "    Players: " + players$ + "   Level: " + level$ + "       Arrow Keys To Move, Esc or Q To Quit."
  311.             GOTO deletecandy:
  312.         END IF
  313.     NEXT wx
  314. NEXT wy
  315.  
  316. 'Check the area around you to delete the candy.
  317. deletecandy:
  318. _LIMIT 3000
  319. FOR wyy = -5 TO INT(h / 3) + 5
  320.     FOR wxx = -5 TO INT(h / 3) + 5
  321.         IF POINT(xx + wxx, yy + wyy) = _RGB32(255, 161, 0) THEN
  322.             FOR cc = 1 TO c
  323.                 IF xx + wxx = candyx(cc) AND yy + wyy = candyy(cc) THEN
  324.                     FOR sz = .25 TO 3 STEP .25
  325.                         CIRCLE (candyx(cc), candyy(cc)), sz, _RGB32(0, 0, 0)
  326.                     NEXT sz
  327.                     SOUND 100, .5
  328.                     co = co + 1
  329.                     mouth = 1
  330.                     oldmsec = TIMER
  331.                 END IF
  332.             NEXT cc
  333.         END IF
  334.     NEXT wxx
  335. NEXT wyy
  336. IF co > 250 THEN
  337.     level = level + 1
  338.     co = 0
  339.     level$ = STR$(level)
  340.     _TITLE "Score: " + sc$ + "   Level: " + level$ + "       Arrow Keys To Move, Esc or Q To Quit."
  341.     GOTO level:
  342.  
  343. you:
  344. _LIMIT 3000
  345. oldxx = xx
  346. oldyy = yy
  347. xx = xx + drx
  348. yy = yy + dry
  349.  
  350. IF xx < 5 THEN xx = 5
  351. IF xx > 795 THEN xx = 795
  352. IF yy < 15 THEN yy = 15
  353. IF yy > 595 THEN yy = 595
  354.  
  355. 'Check to see if you hit the walls.
  356. FOR wx = -1 TO INT(h / 3)
  357.     FOR wy = -1 TO INT(h / 3)
  358.         IF POINT(xx + wx, yy + wy) = _RGB32(col1, col2, col3) THEN
  359.             yy = oldyy: xx = oldxx
  360.             RETURN
  361.         END IF
  362.     NEXT wy
  363. NEXT wx
  364.  
  365. 'Erase and draw you.
  366. LINE (oldxx, oldyy)-(oldxx + INT(h / 3), oldyy + INT(h / 3)), _RGB32(0, 0, 0), BF
  367. LINE (xx, yy)-(xx + INT(h / 3), yy + INT(h / 3)), _RGB32(0, 255, 0), BF
  368. LINE (xx, yy)-(xx + INT(h / 3), yy + 3), _RGB32(139, 116, 105), BF
  369.  
  370. ex1 = (xx + (INT(h / 3) / 2) / 2)
  371. ex2 = (xx + (INT(h / 3) / 2) / .65)
  372. ey = (yy + (INT(h / 3) / 2) / 2)
  373. mx = (xx + (INT(h / 3) / 2))
  374. my = (yy + (INT(h / 2.2) / 2))
  375. ny = (yy + (h / 2.85) / 2)
  376.  
  377. FOR sz = .25 TO 2 STEP .25
  378.     CIRCLE (ex1, ey), sz, _RGB32(0, 127, 255)
  379.     CIRCLE (ex2, ey), sz, _RGB32(0, 127, 255)
  380. NEXT sz
  381. FOR sz = .25 TO 2.5 STEP .25
  382.     CIRCLE (mx, my), sz, _RGB32(0, 0, 0)
  383. NEXT sz
  384.  
  385. IF mouth = 1 THEN
  386.     FOR sz = .25 TO 2.5 STEP .25
  387.         CIRCLE (mx, my), sz, _RGB32(254, 254, 254)
  388.     NEXT sz
  389.     msec = TIMER
  390.     IF msec - oldmsec > .25 THEN mouth = 0
  391.  
  392. FOR sz = .25 TO 1.5 STEP .25
  393.     CIRCLE (mx, ny), sz, _RGB32(127, 128, 127)
  394. NEXT sz
  395. IF h > 74 THEN dl = .003
  396. IF h <= 74 AND h >= 55 THEN dl = .004
  397. IF h < 55 THEN dl = .005
  398.  
« Last Edit: August 28, 2019, 08:35:54 pm by SierraKen »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Search-Man Game
« Reply #1 on: August 29, 2019, 06:56:20 pm »
Has anyone tried this game yet? I'm still working on it and have made it a bit better than before. Instead of having to get all the candies, you only need to get 100 of them. I also made them more inside the maze area than before. Plus I made it so you have to get all the levers, but there has been 1 occasion so far where it wouldn't detect 1 lever so it would be impossible to pass the level. That is what got me thinking, why not just add a countdown clock and when the clock expires, it goes to another level as well. But, of course I ran into a totally different problem... and this one I would like any help from. My main loop only runs when your guy is moving (except when he's hitting the side of the screen for some reason). I've tried it with a SUB and it does the same thing. Then I just tried it the old fashioned way without the TIMER command and just added tt=tt+1 and that is when I found out that the entire loop only runs when your guy is in motion (unless he's on the side like I said). If he's against any wall, the main loop stops. And I have no idea why. There's no GOTO loop that would stop this that I know of. The detection area under "You: " flows well and you can still move around fine which are from commands inside the main loop. Anyway, here's what I have... I hope someone replies. Sorry for so much text on both posts.
Code: QB64: [Select]
  1. _TITLE "Search-Man"
  2. SCREEN _NEWIMAGE(800, 600, 32)
  3. _LIMIT 3000
  4. xx = 350: yy = 300: h = 200
  5. splashscreen:
  6. LINE (xx, yy)-(xx + INT(h / 3), yy + INT(h / 3)), _RGB32(0, 255, 0), BF
  7. LINE (xx, yy)-(xx + INT(h / 3), yy + 3), _RGB32(139, 116, 105), BF
  8. ex1 = (xx + (INT(h / 3) / 2) / 2)
  9. ex2 = (xx + (INT(h / 3) / 2) / .65)
  10. ey = (yy + (INT(h / 3) / 2) / 2)
  11. mx = (xx + (INT(h / 3) / 2))
  12. my = (yy + (INT(h / 2.2) / 2))
  13. ny = (yy + (h / 2.85) / 2)
  14. FOR sz = .25 TO 2 STEP .25
  15.     CIRCLE (ex1, ey), sz, _RGB32(0, 127, 255)
  16.     CIRCLE (ex2, ey), sz, _RGB32(0, 127, 255)
  17. NEXT sz
  18. FOR sz = .25 TO 2.5 STEP .25
  19.     CIRCLE (mx, my), sz, _RGB32(0, 0, 0)
  20. NEXT sz
  21. FOR sz = .25 TO 1.5 STEP .25
  22.     CIRCLE (mx, ny), sz, _RGB32(0, 0, 0)
  23. NEXT sz
  24. mouth:
  25. m = m + 1
  26. IF m > 9 THEN GOTO begin:
  27. IF m = 1 THEN mouth = 0
  28. IF m = 2 THEN mouth = 1
  29. IF m = 3 THEN mouth = 0
  30. IF m = 4 THEN mouth = 1
  31. IF m = 5 THEN mouth = 0
  32. IF m = 6 THEN mouth = 1
  33. IF m = 7 THEN mouth = 0
  34. IF m = 8 THEN mouth = 1
  35. IF m = 9 THEN mouth = 0
  36. IF mouth = 1 THEN
  37.     FOR sz = .25 TO 2.5 STEP .25
  38.         CIRCLE (mx, my), sz, _RGB32(254, 254, 254)
  39.     NEXT sz
  40. IF mouth = 0 THEN
  41.     FOR sz = .25 TO 1.5 STEP .25
  42.         CIRCLE (mx, my), sz, _RGB32(0, 0, 0)
  43.     NEXT sz
  44. GOTO mouth:
  45. begin:
  46. PRINT "                                     Search-Man"
  47. PRINT "                                     by  Ken G."
  48. PRINT "                - Use the arrow keys to guide your green guy around the maze"
  49. PRINT "                  to eat the orange candy."
  50. PRINT "                - Levels change when 100 candies have been eaten and all 5"
  51. PRINT "                  green levers have been used."
  52. PRINT "                - Avoid hitting the randomly placed red bombs."
  53. PRINT "                - The green levers will delete the bombs for 20 seconds."
  54. PRINT "                - You start out with 3 players."
  55. PRINT "                - Every level is different, Good Luck!"
  56. INPUT "                               Press Enter To Begin.", a$
  57. level = 1
  58. sc = 0
  59. players = 3
  60. level$ = STR$(level)
  61.  
  62. 'Start a new level here.
  63. level:
  64. DIM candyx(500), candyy(500)
  65. DIM leverx(200), levery(200)
  66. x = 400: y = 300
  67. t = 0
  68. c = 0
  69. drx = 0: dry = 0
  70. lv = 0: slv = 0: bombs = 0
  71. lev = 0
  72. levers = 5
  73. mouth = 0
  74. h = INT(RND * 60) + 40
  75.  
  76. 'Randomly choose a wall color.
  77. col = INT(RND * 8) + 1
  78. 'green
  79. IF col = 1 THEN
  80.     col1 = 33: col2 = 230: col3 = 7
  81. 'purple
  82. IF col = 2 THEN
  83.     col1 = 152: col2 = 7: col3 = 230
  84. 'yellow
  85. IF col = 3 THEN
  86.     col1 = 247: col2 = 255: col3 = 8
  87. 'orange
  88. IF col = 4 THEN
  89.     col1 = 255: col2 = 156: col3 = 8
  90. 'red
  91. IF col = 5 THEN
  92.     col1 = 255: col2 = 8: col3 = 8
  93. 'blue
  94. IF col = 6 THEN
  95.     col1 = 8: col2 = 131: col3 = 255
  96. 'white
  97. IF col = 7 THEN
  98.     col1 = 255: col2 = 255: col3 = 255
  99. 'greenish-blue
  100. IF col = 8 THEN
  101.     col1 = 10: col2 = 240: col3 = 201
  102.  
  103. 'Make the walls.
  104.     _LIMIT 3000
  105.     again:
  106.     t = t + 1
  107.     IF t = 30000000 THEN EXIT DO
  108.     oldx = x
  109.     oldy = y
  110.     oldd = d
  111.     d = INT(RND * 4) + 1
  112.     IF d = oldd THEN GOTO again:
  113.     IF d = 1 THEN x = x + h
  114.     IF d = 2 THEN x = x - h
  115.     IF d = 3 THEN y = y + h
  116.     IF d = 4 THEN y = y - h
  117.     IF x > 800 - h OR x < h OR y > 600 - h OR y < h THEN x = 400: y = 300: GOTO again:
  118.     IF POINT(x, y) = _RGB32(col1, col2, col3) THEN GOTO again:
  119.     LINE (oldx, oldy)-(x, y), _RGB32(col1, col2, col3)
  120. t = 0
  121. FOR tt = 1 TO INT(1000 / h)
  122.     x2 = INT(RND * 800) + 1
  123.     y2 = INT(RND * 600) + 1
  124.     d2 = INT(RND * 2) + 1
  125.     IF d2 = 1 THEN LINE (x2, y2)-(x2 + h, y2 + h), _RGB32(0, 0, 0), BF
  126.     IF d2 = 2 THEN LINE (x2, y2)-(x2 + h, y2 + h), _RGB32(0, 0, 0), BF
  127. NEXT tt
  128.  
  129. 'Setup the levers
  130.     levers:
  131.     leverx = INT(RND * 600) + 100
  132.     levery = INT(RND * 400) + 100
  133.     'Check for walls.
  134.     FOR cx = -2 TO 7
  135.         FOR cy = -2 TO 17
  136.             IF POINT(leverx + cx, levery + cy) = _RGB32(col1, col2, col3) THEN GOTO levers:
  137.         NEXT cy
  138.     NEXT cx
  139.     'Check for other levers.
  140.     FOR cx = -2 TO 7
  141.         FOR cy = -2 TO 17
  142.             IF POINT(leverx + cx, levery + cy) = _RGB32(22, 255, 122) THEN GOTO levers:
  143.         NEXT cy
  144.     NEXT cx
  145.     LINE (leverx, levery)-(leverx + 5, levery + 15), _RGB32(22, 255, 122), BF
  146.     lev = lev + 1
  147.     leverx(lev) = leverx: levery(lev) = levery
  148.     IF lev = 5 THEN EXIT DO
  149.  
  150. 'Setup the candy.
  151.     candy:
  152.     candyx = INT(RND * 600) + 100
  153.     candyy = INT(RND * 400) + 100
  154.     'Check for walls.
  155.     FOR cx = -7 TO 7
  156.         FOR cy = -7 TO 7
  157.             IF POINT(candyx + cx, candyy + cy) = _RGB32(col1, col2, col3) THEN GOTO candy:
  158.         NEXT cy
  159.     NEXT cx
  160.     'Check for other candy.
  161.     FOR cx = -7 TO 7
  162.         FOR cy = -7 TO 7
  163.             IF POINT(candyx + cx, candyy + cy) = _RGB32(255, 161, 0) THEN GOTO candy:
  164.         NEXT cy
  165.     NEXT cx
  166.     'Check for levers.
  167.     FOR cx = -2 TO 7
  168.         FOR cy = -2 TO 17
  169.             IF POINT(candyx + cx, candyy + cy) = _RGB32(22, 255, 122) THEN GOTO candy:
  170.         NEXT cy
  171.     NEXT cx
  172.     CIRCLE (candyx, candyy), 4, _RGB32(255, 161, 0)
  173.     PAINT (candyx, candyy), _RGB32(255, 161, 0)
  174.     c = c + 1
  175.     candyx(c) = candyx: candyy(c) = candyy
  176.     IF c = 150 THEN EXIT DO
  177.  
  178. 'You are coords xx and yy.
  179. xx = 400
  180. yy = 594
  181. _TITLE "Arrow Keys To Move, Esc or Q To Quit."
  182.  
  183. 'The Main Loop
  184.     _LIMIT 3000
  185.     a$ = INKEY$
  186.     IF a$ = CHR$(0) + CHR$(72) THEN
  187.         dry = -1
  188.         drx = 0
  189.     END IF
  190.     IF a$ = CHR$(0) + CHR$(80) THEN
  191.         dry = 1
  192.         drx = 0
  193.     END IF
  194.     IF a$ = CHR$(0) + CHR$(77) THEN
  195.         drx = 1
  196.         dry = 0
  197.     END IF
  198.     IF a$ = CHR$(0) + CHR$(75) THEN
  199.         drx = -1
  200.         dry = 0
  201.     END IF
  202.     IF a$ = CHR$(27) THEN END
  203.     IF a$ = "q" OR a$ = "Q" THEN END
  204.     GOSUB you:
  205.     GOSUB candy2:
  206.     GOSUB lev:
  207.     GOSUB circles:
  208.  
  209. lev:
  210. _LIMIT 3000
  211. FOR wy = -15 TO INT(h / 3) + 15
  212.     FOR wx = -15 TO INT(h / 3) + 15
  213.         IF POINT(xx + wx, yy + wy) = _RGB32(22, 255, 122) THEN
  214.             GOTO deletelever:
  215.         END IF
  216.     NEXT wx
  217. NEXT wy
  218.  
  219. 'Check the area around you to delete the lever.
  220. deletelever:
  221. _LIMIT 3000
  222. FOR wyy = -5 TO INT(h / 3) + 15
  223.     FOR wxx = -5 TO INT(h / 3) + 5
  224.         IF POINT(xx + wxx, yy + wyy) = _RGB32(22, 255, 122) THEN
  225.             FOR cc = 1 TO lev
  226.                 IF xx + wxx = leverx(cc) AND yy + wyy = levery(cc) THEN
  227.                     LINE (leverx(cc), levery(cc))-(leverx(cc) + 5, levery(cc) + 15), _RGB32(0, 0, 0), BF
  228.                     FOR snd = 450 TO 550 STEP 25
  229.                         SOUND snd, .15
  230.                     NEXT snd
  231.                     rr = 0
  232.                     lv = 1
  233.                     levers = levers - 1
  234.                     IF levers < 0 THEN levers = 0
  235.                     LOCATE 1, 25: PRINT "Levers Left: "; levers
  236.                     oldsecond = TIMER
  237.                 END IF
  238.             NEXT cc
  239.         END IF
  240.     NEXT wxx
  241. NEXT wyy
  242.  
  243. 'The Random Red Bombs
  244. circles:
  245. _LIMIT 3000
  246. IF lv = 1 THEN
  247.     second = TIMER
  248.     IF second - oldsecond > 20 THEN lv = 0: slv = 0: GOTO nexone:
  249.     IF slv = 1 THEN RETURN
  250.     CIRCLE (lx, ly), 15, _RGB32(0, 0, 0)
  251.     CIRCLE (lx2, ly2), 15, _RGB32(0, 0, 0)
  252.     CIRCLE (lx3, ly3), 15, _RGB32(0, 0, 0)
  253.     CIRCLE (lx4, ly4), 15, _RGB32(0, 0, 0)
  254.     slv = 1
  255.     RETURN
  256. nexone:
  257. _LIMIT 3000
  258. IF rr = 1 THEN GOTO skip:
  259. rl = INT(RND * 1000) + 1
  260. IF rl > 975 AND rr = 0 THEN
  261.     lx = INT(RND * 750) + 1
  262.     ly = INT(RND * 500) + 1
  263.     lx2 = INT(RND * 750) + 1
  264.     ly2 = INT(RND * 500) + 1
  265.     lx3 = INT(RND * 750) + 1
  266.     ly3 = INT(RND * 500) + 1
  267.     lx4 = INT(RND * 750) + 1
  268.     ly4 = INT(RND * 500) + 1
  269.     rr = 1
  270. IF rr = 0 THEN RETURN
  271. skip:
  272. _LIMIT 3000
  273. IF bombs = 1 THEN GOTO skip2:
  274. CIRCLE (lx, ly), 15, _RGB32(255, 0, 0)
  275. CIRCLE (lx2, ly2), 15, _RGB32(255, 0, 0)
  276. CIRCLE (lx3, ly3), 15, _RGB32(255, 0, 0)
  277. CIRCLE (lx4, ly4), 15, _RGB32(255, 0, 0)
  278. bombs = 1
  279. skip2:
  280. _LIMIT 3000
  281. IF xx > lx - h / 3 AND xx < lx + h / 3 AND yy > ly - h / 3 AND yy < ly + h / 3 THEN GOSUB KABOOM:
  282. IF xx > lx2 - h / 3 AND xx < lx2 + h / 3 AND yy > ly2 - h / 3 AND yy < ly2 + h / 3 THEN GOSUB KABOOM:
  283. IF xx > lx3 - h / 3 AND xx < lx3 + h / 3 AND yy > ly3 - h / 3 AND yy < ly3 + h / 3 THEN GOSUB KABOOM:
  284. IF xx > lx4 - h / 3 AND xx < lx4 + h / 3 AND yy > ly4 - h / 3 AND yy < ly4 + h / 3 THEN GOSUB KABOOM:
  285. rl2 = INT(RND * 10000) + 1
  286. IF rl2 > 9985 THEN
  287.     rr = 0
  288.     bombs = 0
  289.     CIRCLE (lx, ly), 15, _RGB32(0, 0, 0)
  290.     CIRCLE (lx2, ly2), 15, _RGB32(0, 0, 0)
  291.     CIRCLE (lx3, ly3), 15, _RGB32(0, 0, 0)
  292.     CIRCLE (lx4, ly4), 15, _RGB32(0, 0, 0)
  293.  
  294. KABOOM:
  295. players = players - 1
  296. LINE (xx, yy)-(xx + INT(h / 3), yy + INT(h / 3)), _RGB32(0, 0, 0), BF
  297. CIRCLE (lx, ly), 15, _RGB32(0, 0, 0)
  298. CIRCLE (lx2, ly2), 15, _RGB32(0, 0, 0)
  299. CIRCLE (lx3, ly3), 15, _RGB32(0, 0, 0)
  300. CIRCLE (lx4, ly4), 15, _RGB32(0, 0, 0)
  301. FOR sz = 1 TO 10
  302.     CIRCLE (xx + (h / 3), yy + (h / 3)), sz, _RGB32(255, 0, 0)
  303.     SOUND 100, .25
  304.     _DELAY .1
  305. NEXT sz
  306. FOR sz = 1 TO 10 STEP .25
  307.     CIRCLE (xx + (h / 3), yy + (h / 3)), sz, _RGB32(0, 0, 0)
  308.     _DELAY .01
  309. NEXT sz
  310. xx = 400
  311. yy = 594
  312. rr = 0
  313. slv = 0
  314. bombs = 0
  315. players$ = STR$(players)
  316. _TITLE "Score: " + sc$ + "    Players: " + players$ + "   Level: " + level$ + "       Arrow Keys To Move, Esc or Q To Quit."
  317. IF players = 0 THEN
  318.     LOCATE 15, 45: PRINT "G A M E   O V E R"
  319.     LOCATE 17, 45: INPUT "Again(Y/N)"; ag$
  320.     IF LEFT$(ag$, 1) = "y" OR LEFT$(ag$, 1) = "Y" THEN CLEAR: GOTO begin:
  321.     END
  322.  
  323. 'Check to see if you got a candy.
  324. candy2:
  325. _LIMIT 3000
  326. FOR wy = -5 TO INT(h / 2) + 5
  327.     FOR wx = -5 TO INT(h / 2) + 5
  328.         IF POINT(xx + wx, yy + wy) = _RGB32(255, 161, 0) THEN
  329.             sc = sc + 10
  330.             sc$ = STR$(sc)
  331.             players$ = STR$(players)
  332.             _TITLE "Score: " + sc$ + "    Players: " + players$ + "   Level: " + level$ + "       Arrow Keys To Move, Esc or Q To Quit."
  333.             GOTO deletecandy:
  334.         END IF
  335.     NEXT wx
  336. NEXT wy
  337.  
  338. 'Check the area around you to delete the candy.
  339. deletecandy:
  340. _LIMIT 3000
  341. FOR wyy = -5 TO INT(h / 3) + 5
  342.     FOR wxx = -5 TO INT(h / 3) + 5
  343.         IF POINT(xx + wxx, yy + wyy) = _RGB32(255, 161, 0) THEN
  344.             FOR cc = 1 TO c
  345.                 IF xx + wxx = candyx(cc) AND yy + wyy = candyy(cc) THEN
  346.                     CIRCLE (candyx(cc), candyy(cc)), 4, _RGB32(0, 0, 0)
  347.                     PAINT (candyx(cc), candyy(cc)), _RGB32(0, 0, 0)
  348.                     SOUND 100, .5
  349.                     co = co + 1
  350.                     co2 = 100 - co
  351.                     IF co2 < 0 THEN co2 = 0
  352.                     LOCATE 1, 1: PRINT "Candy To Get: "; co2
  353.                     mouth = 1
  354.                     oldmsec = TIMER
  355.                 END IF
  356.             NEXT cc
  357.         END IF
  358.     NEXT wxx
  359. NEXT wyy
  360. IF co2 = 0 AND levers = 0 THEN
  361.     level = level + 1
  362.     co = 0
  363.     level$ = STR$(level)
  364.     _TITLE "Score: " + sc$ + "   Level: " + level$ + "       Arrow Keys To Move, Esc or Q To Quit."
  365.     GOTO level:
  366.  
  367. you:
  368. _LIMIT 3000
  369. oldxx = xx
  370. oldyy = yy
  371. xx = xx + drx
  372. yy = yy + dry
  373.  
  374. IF xx < 5 THEN xx = 5
  375. IF xx > 795 THEN xx = 795
  376. IF yy < 15 THEN yy = 15
  377. IF yy > 595 THEN yy = 595
  378.  
  379. 'Check to see if you hit the walls.
  380. FOR wx = -1 TO INT(h / 3)
  381.     FOR wy = -1 TO INT(h / 3)
  382.         IF POINT(xx + wx, yy + wy) = _RGB32(col1, col2, col3) THEN
  383.             yy = oldyy: xx = oldxx
  384.             RETURN
  385.         END IF
  386.     NEXT wy
  387. NEXT wx
  388.  
  389. 'Erase and draw you.
  390. LINE (oldxx, oldyy)-(oldxx + INT(h / 3), oldyy + INT(h / 3)), _RGB32(0, 0, 0), BF
  391. LINE (xx, yy)-(xx + INT(h / 3), yy + INT(h / 3)), _RGB32(0, 255, 0), BF
  392. LINE (xx, yy)-(xx + INT(h / 3), yy + 3), _RGB32(139, 116, 105), BF
  393.  
  394. ex1 = (xx + (INT(h / 3) / 2) / 2)
  395. ex2 = (xx + (INT(h / 3) / 2) / .65)
  396. ey = (yy + (INT(h / 3) / 2) / 2)
  397. mx = (xx + (INT(h / 3) / 2))
  398. my = (yy + (INT(h / 2.2) / 2))
  399. ny = (yy + (h / 2.85) / 2)
  400.  
  401. FOR sz = .25 TO 2 STEP .25
  402.     CIRCLE (ex1, ey), sz, _RGB32(0, 127, 255)
  403.     CIRCLE (ex2, ey), sz, _RGB32(0, 127, 255)
  404. NEXT sz
  405. FOR sz = .25 TO 2.5 STEP .25
  406.     CIRCLE (mx, my), sz, _RGB32(0, 0, 0)
  407. NEXT sz
  408.  
  409. IF mouth = 1 THEN
  410.     FOR sz = .25 TO 2.5 STEP .25
  411.         CIRCLE (mx, my), sz, _RGB32(254, 254, 254)
  412.     NEXT sz
  413.     msec = TIMER
  414.     IF msec - oldmsec > .25 THEN mouth = 0
  415.  
  416. FOR sz = .25 TO 1.5 STEP .25
  417.     CIRCLE (mx, ny), sz, _RGB32(127, 128, 127)
  418. NEXT sz
  419. IF h > 74 THEN dl = .003
  420. IF h <= 74 AND h >= 55 THEN dl = .004
  421. IF h < 55 THEN dl = .005
  422.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Search-Man Game
« Reply #2 on: August 29, 2019, 07:16:01 pm »
Quote
Has anyone tried this game yet?

Hi Ken,

I did try the original post, same old problem with arrow keys, I press one arrow guy crashes into wall until I press another arrow > crash, another, crash, not much fun for me. Your computer must run slower, you can control frames with _limit so everyone's speed is same.  _limit 3000 is not slowing anything down to human level.

« Last Edit: August 29, 2019, 07:37:05 pm by bplus »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Search-Man Game
« Reply #3 on: August 29, 2019, 08:05:16 pm »
Interesting.. I have a very fast computer by the way, 64 bit Windows 10 16 GB RAM Intel i7 Quadcore 3.4 Ghz. It's only around 4 years old.
And the reason I had to boost it up to _LIMIT 3000 on the whole program is because any slower than that, the program couldn't run practically at all, or ran on a crawl.
I know you are going to say I should have used SUB's on many parts of the program, which probably would have made it run smoother and probably faster, but I do not have the experience needed in order to do them. The few times I've tried to speed up a program with SUB's, it just didn't work. Anyways, thank you for at least trying. Since you cannot run this game, I will probably not post anymore about it here, unless someone else can play it.
« Last Edit: August 29, 2019, 08:08:35 pm by SierraKen »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Search-Man Game
« Reply #4 on: August 29, 2019, 10:42:49 pm »
I do like the 2nd version more than first, I tried setting all _LIMIT 3000 to 60 all 50 of them. (I exaggerate only 49) ;D

and see what you mean about s l o w w w

so I uped the drx, dry better... man! you have a slow keypress response, how many _DELAYs are roaming around in there?

I will check

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Search-Man Game
« Reply #5 on: August 29, 2019, 10:59:43 pm »
Here tis the slower downer
Code: QB64: [Select]
  1. IF mouth = 1 THEN
  2.     FOR sz = .25 TO 2.5 STEP .25
  3.         CIRCLE (mx, my), sz, _RGB32(254, 254, 254)
  4.     NEXT sz
  5.     msec = TIMER
  6.     IF msec - oldmsec > .25 THEN mouth = 0
  7.  
  8. FOR sz = .25 TO 1.5 STEP .25
  9.     CIRCLE (mx, ny), sz, _RGB32(127, 128, 127)
  10. NEXT sz
  11. IF h > 74 THEN dl = .003
  12. IF h <= 74 AND h >= 55 THEN dl = .004
  13. IF h < 55 THEN dl = .005
  14.  

You can change mouth size while cycling through loops, instead of stopping whole program to move the mouth, it's cute alright though!

Move mouth through a loopcnt in main loop
if loopcnt mod 10 = 0 then do something
if loopcnt mod 10 = 1 then do next thing
if loopcnt mod 10 = 2 then do next thing
...
up to 9 then you start over, does NOT have to be mod 10 should be mod how many steps in the cycle to move all the way through sequence. 9 cycles back to 0 when using mod 10

eh shoulda tried it first, be right back..

Oh the mouth thing is fine, the _delay is for?

OK I got rid of all _LIMITs except one in main loop and set it 200, OK then I switched to mouse and saved the maze image to bg& and then see how you have your candy locations in arrays to redraw over bg& of maze. Looking for how you know which candy is eaten, need another array eaten?
« Last Edit: August 29, 2019, 11:47:54 pm by bplus »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Search-Man Game
« Reply #6 on: August 29, 2019, 11:42:31 pm »
Thanks, but the mouth also uses 2 TIMER's to know how long to shut. I wonder if that can work?
« Last Edit: August 29, 2019, 11:45:21 pm by SierraKen »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Search-Man Game
« Reply #7 on: August 29, 2019, 11:49:25 pm »
Here are the sections with both timers. The first one, oldmsec =  TIMER starts as soon as you delete a candy. That makes mouth = 1. Then on the section you posted it asks IF mouth = 1 to see how long he bites down for. Here is all of it:

Code: QB64: [Select]
  1. deletecandy:
  2. _LIMIT 3000
  3. FOR wyy = -5 TO INT(h / 3) + 5
  4.     FOR wxx = -5 TO INT(h / 3) + 5
  5.         IF POINT(xx + wxx, yy + wyy) = _RGB32(255, 161, 0) THEN
  6.             FOR cc = 1 TO c
  7.                 IF xx + wxx = candyx(cc) AND yy + wyy = candyy(cc) THEN
  8.                     CIRCLE (candyx(cc), candyy(cc)), 4, _RGB32(0, 0, 0)
  9.                     PAINT (candyx(cc), candyy(cc)), _RGB32(0, 0, 0)
  10.                     SOUND 100, .5
  11.                     co = co + 1
  12.                     co2 = 100 - co
  13.                     IF co2 < 0 THEN co2 = 0
  14.                     LOCATE 1, 1: PRINT "Candy To Get: "; co2
  15.                     mouth = 1
  16.                     oldmsec = TIMER
  17.                 END IF
  18.             NEXT cc
  19.         END IF
  20.     NEXT wxx
  21. NEXT wyy
  22. IF co2 = 0 AND levers = 0 THEN
  23.     level = level + 1
  24.     co = 0
  25.     level$ = STR$(level)
  26.     _TITLE "Score: " + sc$ + "   Level: " + level$ + "       Arrow Keys To Move, Esc or Q To Quit."
  27.     GOTO level:
  28.  
  29. you:
  30. _LIMIT 3000
  31. oldxx = xx
  32. oldyy = yy
  33. xx = xx + drx
  34. yy = yy + dry
  35.  
  36. IF xx < 5 THEN xx = 5
  37. IF xx > 795 THEN xx = 795
  38. IF yy < 15 THEN yy = 15
  39. IF yy > 595 THEN yy = 595
  40.  
  41. 'Check to see if you hit the walls.
  42. FOR wx = -1 TO INT(h / 3)
  43.     FOR wy = -1 TO INT(h / 3)
  44.         IF POINT(xx + wx, yy + wy) = _RGB32(col1, col2, col3) THEN
  45.             yy = oldyy: xx = oldxx
  46.             RETURN
  47.         END IF
  48.     NEXT wy
  49. NEXT wx
  50.  
  51. 'Erase and draw you.
  52. LINE (oldxx, oldyy)-(oldxx + INT(h / 3), oldyy + INT(h / 3)), _RGB32(0, 0, 0), BF
  53. LINE (xx, yy)-(xx + INT(h / 3), yy + INT(h / 3)), _RGB32(0, 255, 0), BF
  54. LINE (xx, yy)-(xx + INT(h / 3), yy + 3), _RGB32(139, 116, 105), BF
  55.  
  56. ex1 = (xx + (INT(h / 3) / 2) / 2)
  57. ex2 = (xx + (INT(h / 3) / 2) / .65)
  58. ey = (yy + (INT(h / 3) / 2) / 2)
  59. mx = (xx + (INT(h / 3) / 2))
  60. my = (yy + (INT(h / 2.2) / 2))
  61. ny = (yy + (h / 2.85) / 2)
  62.  
  63. FOR sz = .25 TO 2 STEP .25
  64.     CIRCLE (ex1, ey), sz, _RGB32(0, 127, 255)
  65.     CIRCLE (ex2, ey), sz, _RGB32(0, 127, 255)
  66. NEXT sz
  67. FOR sz = .25 TO 2.5 STEP .25
  68.     CIRCLE (mx, my), sz, _RGB32(0, 0, 0)
  69. NEXT sz
  70.  
  71. IF mouth = 1 THEN
  72.     FOR sz = .25 TO 2.5 STEP .25
  73.         CIRCLE (mx, my), sz, _RGB32(254, 254, 254)
  74.     NEXT sz
  75.     msec = TIMER
  76.     IF msec - oldmsec > .25 THEN mouth = 0
  77.  
  78. FOR sz = .25 TO 1.5 STEP .25
  79.     CIRCLE (mx, ny), sz, _RGB32(127, 128, 127)
  80. NEXT sz
  81. IF h > 74 THEN dl = .003
  82. IF h <= 74 AND h >= 55 THEN dl = .004
  83. IF h < 55 THEN dl = .005
  84.  
« Last Edit: August 29, 2019, 11:51:50 pm by SierraKen »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Search-Man Game
« Reply #8 on: August 29, 2019, 11:56:42 pm »
Mouths aren't problem, they are cool! I've not seen it done like that with timer, Good!

I hate arrow keys so started makeover with mouse, need arrays to track candy and levers still remaining so I can redraw them over a maze image I saved after it is drawn. Guess I need to figure away for dropping hero if I try to go through a wall with it :D

I think you only need one _limit in the main loop. Ha! and one Randomize Timer at start of game.
« Last Edit: August 30, 2019, 12:00:46 am by bplus »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Search-Man Game
« Reply #9 on: August 30, 2019, 12:08:29 am »
Ah that's great you are working on it! But please also check this version I just now did. I removed 3 loops entirely in the mouth and nose section. 2 of them are for the mouth (open and close), and then the tiny nose. Instead I am drawing it with just 1 CIRCLE each and 1 PAINT each. This should make game play a bit better. Try mine and rename mine so you can have both yours and mine.
Yeah, I tried doing arrays to capture the candy but for some reason it wouldn't work, not sure why. But I do have arrays for the candy and levers anyway so I know exactly where to erase them. I just don't detect them with arrays, instead I use POINT for the colors. But try out this version and tell me what you think. I'll still look over it more too, probably tomorrow. Thank you very much B+, I was really afraid nobody would try this game I've worked a week on already.

Code: QB64: [Select]
  1. _TITLE "Search-Man"
  2. SCREEN _NEWIMAGE(800, 600, 32)
  3. _LIMIT 3000
  4. xx = 350: yy = 300: h = 200
  5. splashscreen:
  6. LINE (xx, yy)-(xx + INT(h / 3), yy + INT(h / 3)), _RGB32(0, 255, 0), BF
  7. LINE (xx, yy)-(xx + INT(h / 3), yy + 3), _RGB32(139, 116, 105), BF
  8. ex1 = (xx + (INT(h / 3) / 2) / 2)
  9. ex2 = (xx + (INT(h / 3) / 2) / .65)
  10. ey = (yy + (INT(h / 3) / 2) / 2)
  11. mx = (xx + (INT(h / 3) / 2))
  12. my = (yy + (INT(h / 2.2) / 2))
  13. ny = (yy + (h / 2.85) / 2)
  14. FOR sz = .25 TO 2 STEP .25
  15.     CIRCLE (ex1, ey), sz, _RGB32(0, 127, 255)
  16.     CIRCLE (ex2, ey), sz, _RGB32(0, 127, 255)
  17. NEXT sz
  18. FOR sz = .25 TO 2.5 STEP .25
  19.     CIRCLE (mx, my), sz, _RGB32(0, 0, 0)
  20. NEXT sz
  21. FOR sz = .25 TO 1.5 STEP .25
  22.     CIRCLE (mx, ny), sz, _RGB32(0, 0, 0)
  23. NEXT sz
  24. mouth:
  25. m = m + 1
  26. IF m > 9 THEN GOTO begin:
  27. IF m = 1 THEN mouth = 0
  28. IF m = 2 THEN mouth = 1
  29. IF m = 3 THEN mouth = 0
  30. IF m = 4 THEN mouth = 1
  31. IF m = 5 THEN mouth = 0
  32. IF m = 6 THEN mouth = 1
  33. IF m = 7 THEN mouth = 0
  34. IF m = 8 THEN mouth = 1
  35. IF m = 9 THEN mouth = 0
  36. IF mouth = 1 THEN
  37.     FOR sz = .25 TO 2.5 STEP .25
  38.         CIRCLE (mx, my), sz, _RGB32(254, 254, 254)
  39.     NEXT sz
  40. IF mouth = 0 THEN
  41.     FOR sz = .25 TO 1.5 STEP .25
  42.         CIRCLE (mx, my), sz, _RGB32(0, 0, 0)
  43.     NEXT sz
  44. GOTO mouth:
  45. begin:
  46. PRINT "                                     Search-Man"
  47. PRINT "                                     by  Ken G."
  48. PRINT "                - Use the arrow keys to guide your green guy around the maze"
  49. PRINT "                  to eat the orange candy."
  50. PRINT "                - Levels change when 100 candies have been eaten and all 5"
  51. PRINT "                  green levers have been used."
  52. PRINT "                - Avoid hitting the randomly placed red bombs."
  53. PRINT "                - The green levers will delete the bombs for 20 seconds."
  54. PRINT "                - You start out with 3 players."
  55. PRINT "                - Every level is different, Good Luck!"
  56. INPUT "                               Press Enter To Begin.", a$
  57. level = 1
  58. sc = 0
  59. players = 3
  60. level$ = STR$(level)
  61.  
  62. 'Start a new level here.
  63. level:
  64. DIM candyx(500), candyy(500)
  65. DIM leverx(200), levery(200)
  66. x = 400: y = 300
  67. t = 0
  68. c = 0
  69. drx = 0: dry = 0
  70. lv = 0: slv = 0: bombs = 0
  71. lev = 0
  72. levers = 5
  73. mouth = 0
  74. h = INT(RND * 60) + 40
  75.  
  76. 'Randomly choose a wall color.
  77. col = INT(RND * 8) + 1
  78. 'green
  79. IF col = 1 THEN
  80.     col1 = 33: col2 = 230: col3 = 7
  81. 'purple
  82. IF col = 2 THEN
  83.     col1 = 152: col2 = 7: col3 = 230
  84. 'yellow
  85. IF col = 3 THEN
  86.     col1 = 247: col2 = 255: col3 = 8
  87. 'orange
  88. IF col = 4 THEN
  89.     col1 = 255: col2 = 156: col3 = 8
  90. 'red
  91. IF col = 5 THEN
  92.     col1 = 255: col2 = 8: col3 = 8
  93. 'blue
  94. IF col = 6 THEN
  95.     col1 = 8: col2 = 131: col3 = 255
  96. 'white
  97. IF col = 7 THEN
  98.     col1 = 255: col2 = 255: col3 = 255
  99. 'greenish-blue
  100. IF col = 8 THEN
  101.     col1 = 10: col2 = 240: col3 = 201
  102.  
  103. 'Make the walls.
  104.     _LIMIT 3000
  105.     again:
  106.     t = t + 1
  107.     IF t = 30000000 THEN EXIT DO
  108.     oldx = x
  109.     oldy = y
  110.     oldd = d
  111.     d = INT(RND * 4) + 1
  112.     IF d = oldd THEN GOTO again:
  113.     IF d = 1 THEN x = x + h
  114.     IF d = 2 THEN x = x - h
  115.     IF d = 3 THEN y = y + h
  116.     IF d = 4 THEN y = y - h
  117.     IF x > 800 - h OR x < h OR y > 600 - h OR y < h THEN x = 400: y = 300: GOTO again:
  118.     IF POINT(x, y) = _RGB32(col1, col2, col3) THEN GOTO again:
  119.     LINE (oldx, oldy)-(x, y), _RGB32(col1, col2, col3)
  120. t = 0
  121. FOR tt = 1 TO INT(1000 / h)
  122.     x2 = INT(RND * 800) + 1
  123.     y2 = INT(RND * 600) + 1
  124.     d2 = INT(RND * 2) + 1
  125.     IF d2 = 1 THEN LINE (x2, y2)-(x2 + h, y2 + h), _RGB32(0, 0, 0), BF
  126.     IF d2 = 2 THEN LINE (x2, y2)-(x2 + h, y2 + h), _RGB32(0, 0, 0), BF
  127. NEXT tt
  128.  
  129. 'Setup the levers
  130.     levers:
  131.     leverx = INT(RND * 600) + 100
  132.     levery = INT(RND * 400) + 100
  133.     'Check for walls.
  134.     FOR cx = -2 TO 7
  135.         FOR cy = -2 TO 17
  136.             IF POINT(leverx + cx, levery + cy) = _RGB32(col1, col2, col3) THEN GOTO levers:
  137.         NEXT cy
  138.     NEXT cx
  139.     'Check for other levers.
  140.     FOR cx = -2 TO 7
  141.         FOR cy = -2 TO 17
  142.             IF POINT(leverx + cx, levery + cy) = _RGB32(22, 255, 122) THEN GOTO levers:
  143.         NEXT cy
  144.     NEXT cx
  145.     LINE (leverx, levery)-(leverx + 5, levery + 15), _RGB32(22, 255, 122), BF
  146.     lev = lev + 1
  147.     leverx(lev) = leverx: levery(lev) = levery
  148.     IF lev = 5 THEN EXIT DO
  149.  
  150. 'Setup the candy.
  151.     candy:
  152.     candyx = INT(RND * 600) + 100
  153.     candyy = INT(RND * 400) + 100
  154.     'Check for walls.
  155.     FOR cx = -7 TO 7
  156.         FOR cy = -7 TO 7
  157.             IF POINT(candyx + cx, candyy + cy) = _RGB32(col1, col2, col3) THEN GOTO candy:
  158.         NEXT cy
  159.     NEXT cx
  160.     'Check for other candy.
  161.     FOR cx = -7 TO 7
  162.         FOR cy = -7 TO 7
  163.             IF POINT(candyx + cx, candyy + cy) = _RGB32(255, 161, 0) THEN GOTO candy:
  164.         NEXT cy
  165.     NEXT cx
  166.     'Check for levers.
  167.     FOR cx = -2 TO 7
  168.         FOR cy = -2 TO 17
  169.             IF POINT(candyx + cx, candyy + cy) = _RGB32(22, 255, 122) THEN GOTO candy:
  170.         NEXT cy
  171.     NEXT cx
  172.     CIRCLE (candyx, candyy), 4, _RGB32(255, 161, 0)
  173.     PAINT (candyx, candyy), _RGB32(255, 161, 0)
  174.     c = c + 1
  175.     candyx(c) = candyx: candyy(c) = candyy
  176.     IF c = 150 THEN EXIT DO
  177.  
  178. 'You are coords xx and yy.
  179. xx = 400
  180. yy = 594
  181. _TITLE "Arrow Keys To Move, Esc or Q To Quit."
  182.  
  183. 'The Main Loop
  184.     _LIMIT 3000
  185.     a$ = INKEY$
  186.     IF a$ = CHR$(0) + CHR$(72) THEN
  187.         dry = -1
  188.         drx = 0
  189.     END IF
  190.     IF a$ = CHR$(0) + CHR$(80) THEN
  191.         dry = 1
  192.         drx = 0
  193.     END IF
  194.     IF a$ = CHR$(0) + CHR$(77) THEN
  195.         drx = 1
  196.         dry = 0
  197.     END IF
  198.     IF a$ = CHR$(0) + CHR$(75) THEN
  199.         drx = -1
  200.         dry = 0
  201.     END IF
  202.     IF a$ = CHR$(27) THEN END
  203.     IF a$ = "q" OR a$ = "Q" THEN END
  204.     GOSUB you:
  205.     GOSUB candy2:
  206.     GOSUB lev:
  207.     GOSUB circles:
  208.  
  209. lev:
  210. _LIMIT 3000
  211. FOR wy = -15 TO INT(h / 3) + 15
  212.     FOR wx = -15 TO INT(h / 3) + 15
  213.         IF POINT(xx + wx, yy + wy) = _RGB32(22, 255, 122) THEN
  214.             GOTO deletelever:
  215.         END IF
  216.     NEXT wx
  217. NEXT wy
  218.  
  219. 'Check the area around you to delete the lever.
  220. deletelever:
  221. _LIMIT 3000
  222. FOR wyy = -5 TO INT(h / 3) + 15
  223.     FOR wxx = -5 TO INT(h / 3) + 5
  224.         IF POINT(xx + wxx, yy + wyy) = _RGB32(22, 255, 122) THEN
  225.             FOR cc = 1 TO lev
  226.                 IF xx + wxx = leverx(cc) AND yy + wyy = levery(cc) THEN
  227.                     LINE (leverx(cc), levery(cc))-(leverx(cc) + 5, levery(cc) + 15), _RGB32(0, 0, 0), BF
  228.                     FOR snd = 450 TO 550 STEP 25
  229.                         SOUND snd, .15
  230.                     NEXT snd
  231.                     rr = 0
  232.                     lv = 1
  233.                     levers = levers - 1
  234.                     IF levers < 0 THEN levers = 0
  235.                     LOCATE 1, 25: PRINT "Levers Left: "; levers
  236.                     oldsecond = TIMER
  237.                 END IF
  238.             NEXT cc
  239.         END IF
  240.     NEXT wxx
  241. NEXT wyy
  242.  
  243. 'The Random Red Bombs
  244. circles:
  245. _LIMIT 3000
  246. IF lv = 1 THEN
  247.     second = TIMER
  248.     IF second - oldsecond > 20 THEN lv = 0: slv = 0: GOTO nexone:
  249.     IF slv = 1 THEN RETURN
  250.     CIRCLE (lx, ly), 15, _RGB32(0, 0, 0)
  251.     CIRCLE (lx2, ly2), 15, _RGB32(0, 0, 0)
  252.     CIRCLE (lx3, ly3), 15, _RGB32(0, 0, 0)
  253.     CIRCLE (lx4, ly4), 15, _RGB32(0, 0, 0)
  254.     slv = 1
  255.     RETURN
  256. nexone:
  257. _LIMIT 3000
  258. IF rr = 1 THEN GOTO skip:
  259. rl = INT(RND * 1000) + 1
  260. IF rl > 975 AND rr = 0 THEN
  261.     lx = INT(RND * 750) + 1
  262.     ly = INT(RND * 500) + 1
  263.     lx2 = INT(RND * 750) + 1
  264.     ly2 = INT(RND * 500) + 1
  265.     lx3 = INT(RND * 750) + 1
  266.     ly3 = INT(RND * 500) + 1
  267.     lx4 = INT(RND * 750) + 1
  268.     ly4 = INT(RND * 500) + 1
  269.     rr = 1
  270. IF rr = 0 THEN RETURN
  271. skip:
  272. _LIMIT 3000
  273. IF bombs = 1 THEN GOTO skip2:
  274. CIRCLE (lx, ly), 15, _RGB32(255, 0, 0)
  275. CIRCLE (lx2, ly2), 15, _RGB32(255, 0, 0)
  276. CIRCLE (lx3, ly3), 15, _RGB32(255, 0, 0)
  277. CIRCLE (lx4, ly4), 15, _RGB32(255, 0, 0)
  278. bombs = 1
  279. skip2:
  280. _LIMIT 3000
  281. IF xx > lx - h / 3 AND xx < lx + h / 3 AND yy > ly - h / 3 AND yy < ly + h / 3 THEN GOSUB KABOOM:
  282. IF xx > lx2 - h / 3 AND xx < lx2 + h / 3 AND yy > ly2 - h / 3 AND yy < ly2 + h / 3 THEN GOSUB KABOOM:
  283. IF xx > lx3 - h / 3 AND xx < lx3 + h / 3 AND yy > ly3 - h / 3 AND yy < ly3 + h / 3 THEN GOSUB KABOOM:
  284. IF xx > lx4 - h / 3 AND xx < lx4 + h / 3 AND yy > ly4 - h / 3 AND yy < ly4 + h / 3 THEN GOSUB KABOOM:
  285. rl2 = INT(RND * 10000) + 1
  286. IF rl2 > 9985 THEN
  287.     rr = 0
  288.     bombs = 0
  289.     CIRCLE (lx, ly), 15, _RGB32(0, 0, 0)
  290.     CIRCLE (lx2, ly2), 15, _RGB32(0, 0, 0)
  291.     CIRCLE (lx3, ly3), 15, _RGB32(0, 0, 0)
  292.     CIRCLE (lx4, ly4), 15, _RGB32(0, 0, 0)
  293.  
  294. KABOOM:
  295. players = players - 1
  296. LINE (xx, yy)-(xx + INT(h / 3), yy + INT(h / 3)), _RGB32(0, 0, 0), BF
  297. CIRCLE (lx, ly), 15, _RGB32(0, 0, 0)
  298. CIRCLE (lx2, ly2), 15, _RGB32(0, 0, 0)
  299. CIRCLE (lx3, ly3), 15, _RGB32(0, 0, 0)
  300. CIRCLE (lx4, ly4), 15, _RGB32(0, 0, 0)
  301. FOR sz = 1 TO 10
  302.     CIRCLE (xx + (h / 3), yy + (h / 3)), sz, _RGB32(255, 0, 0)
  303.     SOUND 100, .25
  304.     _DELAY .1
  305. NEXT sz
  306. FOR sz = 1 TO 10 STEP .25
  307.     CIRCLE (xx + (h / 3), yy + (h / 3)), sz, _RGB32(0, 0, 0)
  308.     _DELAY .01
  309. NEXT sz
  310. xx = 400
  311. yy = 594
  312. rr = 0
  313. slv = 0
  314. bombs = 0
  315. players$ = STR$(players)
  316. _TITLE "Score: " + sc$ + "    Players: " + players$ + "   Level: " + level$ + "       Arrow Keys To Move, Esc or Q To Quit."
  317. IF players = 0 THEN
  318.     LOCATE 15, 45: PRINT "G A M E   O V E R"
  319.     LOCATE 17, 45: INPUT "Again(Y/N)"; ag$
  320.     IF LEFT$(ag$, 1) = "y" OR LEFT$(ag$, 1) = "Y" THEN CLEAR: GOTO begin:
  321.     END
  322.  
  323. 'Check to see if you got a candy.
  324. candy2:
  325. _LIMIT 3000
  326. FOR wy = -5 TO INT(h / 2) + 5
  327.     FOR wx = -5 TO INT(h / 2) + 5
  328.         IF POINT(xx + wx, yy + wy) = _RGB32(255, 161, 0) THEN
  329.             sc = sc + 10
  330.             sc$ = STR$(sc)
  331.             players$ = STR$(players)
  332.             _TITLE "Score: " + sc$ + "    Players: " + players$ + "   Level: " + level$ + "       Arrow Keys To Move, Esc or Q To Quit."
  333.             GOTO deletecandy:
  334.         END IF
  335.     NEXT wx
  336. NEXT wy
  337.  
  338. 'Check the area around you to delete the candy.
  339. deletecandy:
  340. _LIMIT 3000
  341. FOR wyy = -5 TO INT(h / 3) + 5
  342.     FOR wxx = -5 TO INT(h / 3) + 5
  343.         IF POINT(xx + wxx, yy + wyy) = _RGB32(255, 161, 0) THEN
  344.             FOR cc = 1 TO c
  345.                 IF xx + wxx = candyx(cc) AND yy + wyy = candyy(cc) THEN
  346.                     CIRCLE (candyx(cc), candyy(cc)), 4, _RGB32(0, 0, 0)
  347.                     PAINT (candyx(cc), candyy(cc)), _RGB32(0, 0, 0)
  348.                     SOUND 100, .5
  349.                     co = co + 1
  350.                     co2 = 100 - co
  351.                     IF co2 < 0 THEN co2 = 0
  352.                     LOCATE 1, 1: PRINT "Candy To Get: "; co2
  353.                     mouth = 1
  354.                     oldmsec = TIMER
  355.                 END IF
  356.             NEXT cc
  357.         END IF
  358.     NEXT wxx
  359. NEXT wyy
  360. IF co2 = 0 AND levers = 0 THEN
  361.     level = level + 1
  362.     co = 0
  363.     level$ = STR$(level)
  364.     _TITLE "Score: " + sc$ + "   Level: " + level$ + "       Arrow Keys To Move, Esc or Q To Quit."
  365.     GOTO level:
  366.  
  367. you:
  368. _LIMIT 3000
  369. oldxx = xx
  370. oldyy = yy
  371. xx = xx + drx
  372. yy = yy + dry
  373.  
  374. IF xx < 5 THEN xx = 5
  375. IF xx > 795 THEN xx = 795
  376. IF yy < 15 THEN yy = 15
  377. IF yy > 595 THEN yy = 595
  378.  
  379. 'Check to see if you hit the walls.
  380. FOR wx = -1 TO INT(h / 3)
  381.     FOR wy = -1 TO INT(h / 3)
  382.         IF POINT(xx + wx, yy + wy) = _RGB32(col1, col2, col3) THEN
  383.             yy = oldyy: xx = oldxx
  384.             RETURN
  385.         END IF
  386.     NEXT wy
  387. NEXT wx
  388.  
  389. 'Erase and draw you.
  390. LINE (oldxx, oldyy)-(oldxx + INT(h / 3), oldyy + INT(h / 3)), _RGB32(0, 0, 0), BF
  391. LINE (xx, yy)-(xx + INT(h / 3), yy + INT(h / 3)), _RGB32(0, 255, 0), BF
  392. LINE (xx, yy)-(xx + INT(h / 3), yy + 3), _RGB32(139, 116, 105), BF
  393.  
  394. ex1 = (xx + (INT(h / 3) / 2) / 2)
  395. ex2 = (xx + (INT(h / 3) / 2) / .65)
  396. ey = (yy + (INT(h / 3) / 2) / 2)
  397. mx = (xx + (INT(h / 3) / 2))
  398. my = (yy + (INT(h / 2.2) / 2))
  399. ny = (yy + (h / 2.85) / 2)
  400.  
  401. FOR sz = .25 TO 2 STEP .25
  402.     CIRCLE (ex1, ey), sz, _RGB32(0, 127, 255)
  403.     CIRCLE (ex2, ey), sz, _RGB32(0, 127, 255)
  404. NEXT sz
  405. IF mouth = 1 THEN GOTO skip3:
  406. CIRCLE (mx, my), 2.5, _RGB32(0, 0, 0)
  407. PAINT (mx, my), _RGB32(0, 0, 0)
  408. skip3:
  409. IF mouth = 1 THEN
  410.     CIRCLE (mx, my), 2.5, _RGB32(254, 254, 254)
  411.     PAINT (mx, my), _RGB32(254, 254, 254)
  412.     msec = TIMER
  413.     IF msec - oldmsec > .25 THEN mouth = 0
  414.  
  415. CIRCLE (mx, ny), 1.5, _RGB32(127, 128, 127)
  416. PAINT (mx, ny), _RGB32(127, 128, 127)
  417.  
  418. IF h > 74 THEN dl = .003
  419. IF h <= 74 AND h >= 55 THEN dl = .004
  420. IF h < 55 THEN dl = .005
  421.  
  422.  


Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Search-Man Game
« Reply #10 on: August 30, 2019, 12:20:20 am »
Hi Ken,

While I check out your latest you can test drive my mouse through your mazes with candy and levers.

Code: QB64: [Select]
  1. _TITLE "Search-Man"
  2. SCREEN _NEWIMAGE(800, 600, 32)
  3.  
  4. xx = 350: yy = 300: h = 200
  5. splashscreen:
  6. LINE (xx, yy)-(xx + INT(h / 3), yy + INT(h / 3)), _RGB32(0, 255, 0), BF
  7. LINE (xx, yy)-(xx + INT(h / 3), yy + 3), _RGB32(139, 116, 105), BF
  8. ex1 = (xx + (INT(h / 3) / 2) / 2)
  9. ex2 = (xx + (INT(h / 3) / 2) / .65)
  10. ey = (yy + (INT(h / 3) / 2) / 2)
  11. mx = (xx + (INT(h / 3) / 2))
  12. my = (yy + (INT(h / 2.2) / 2))
  13. ny = (yy + (h / 2.85) / 2)
  14. FOR sz = .25 TO 2 STEP .25
  15.     CIRCLE (ex1, ey), sz, _RGB32(0, 127, 255)
  16.     CIRCLE (ex2, ey), sz, _RGB32(0, 127, 255)
  17. NEXT sz
  18. FOR sz = .25 TO 2.5 STEP .25
  19.     CIRCLE (mx, my), sz, _RGB32(0, 0, 0)
  20. NEXT sz
  21. FOR sz = .25 TO 1.5 STEP .25
  22.     CIRCLE (mx, ny), sz, _RGB32(0, 0, 0)
  23. NEXT sz
  24. mouth:
  25. m = m + 1
  26. IF m > 9 THEN GOTO begin:
  27. IF m = 1 THEN mouth = 0
  28. IF m = 2 THEN mouth = 1
  29. IF m = 3 THEN mouth = 0
  30. IF m = 4 THEN mouth = 1
  31. IF m = 5 THEN mouth = 0
  32. IF m = 6 THEN mouth = 1
  33. IF m = 7 THEN mouth = 0
  34. IF m = 8 THEN mouth = 1
  35. IF m = 9 THEN mouth = 0
  36. IF mouth = 1 THEN
  37.     FOR sz = .25 TO 2.5 STEP .25
  38.         CIRCLE (mx, my), sz, _RGB32(254, 254, 254)
  39.     NEXT sz
  40. IF mouth = 0 THEN
  41.     FOR sz = .25 TO 1.5 STEP .25
  42.         CIRCLE (mx, my), sz, _RGB32(0, 0, 0)
  43.     NEXT sz
  44. '_DELAY .5
  45. GOTO mouth:
  46. begin:
  47. PRINT "                                     Search-Man"
  48. PRINT "                                     by  Ken G."
  49. PRINT "                - Use the arrow keys to guide your green guy around the maze"
  50. PRINT "                  to eat the orange candy."
  51. PRINT "                - Levels change when 100 candies have been eaten and all 5"
  52. PRINT "                  green levers have been used."
  53. PRINT "                - Avoid hitting the randomly placed red bombs."
  54. PRINT "                - The green levers will delete the bombs for 20 seconds."
  55. PRINT "                - You start out with 3 players."
  56. PRINT "                - Every level is different, Good Luck!"
  57. INPUT "                               Press Enter To Begin.", a$
  58. level = 1
  59. sc = 0
  60. players = 3
  61. level$ = STR$(level)
  62.  
  63. 'Start a new level here.
  64. level:
  65. DIM candyx(500), candyy(500)
  66. DIM leverx(200), levery(200)
  67. x = 400: y = 300
  68. t = 0
  69. c = 0
  70. drx = 0: dry = 0
  71. lv = 0: slv = 0: bombs = 0
  72. lev = 0
  73. levers = 5
  74. mouth = 0
  75. 'randomize timer
  76. h = INT(RND * 60) + 40
  77.  
  78. 'Randomly choose a wall color.
  79. 'randomize timer
  80. col = INT(RND * 8) + 1
  81. 'green
  82. IF col = 1 THEN
  83.     col1 = 33: col2 = 230: col3 = 7
  84. 'purple
  85. IF col = 2 THEN
  86.     col1 = 152: col2 = 7: col3 = 230
  87. 'yellow
  88. IF col = 3 THEN
  89.     col1 = 247: col2 = 255: col3 = 8
  90. 'orange
  91. IF col = 4 THEN
  92.     col1 = 255: col2 = 156: col3 = 8
  93. 'red
  94. IF col = 5 THEN
  95.     col1 = 255: col2 = 8: col3 = 8
  96. 'blue
  97. IF col = 6 THEN
  98.     col1 = 8: col2 = 131: col3 = 255
  99. 'white
  100. IF col = 7 THEN
  101.     col1 = 255: col2 = 255: col3 = 255
  102. 'greenish-blue
  103. IF col = 8 THEN
  104.     col1 = 10: col2 = 240: col3 = 201
  105.  
  106. 'Make the walls.
  107.  
  108.     again:
  109.     t = t + 1
  110.     IF t = 30000000 THEN EXIT DO
  111.     oldx = x
  112.     oldy = y
  113.     oldd = d
  114.     'randomize timer
  115.     d = INT(RND * 4) + 1
  116.     IF d = oldd THEN GOTO again:
  117.     IF d = 1 THEN x = x + h
  118.     IF d = 2 THEN x = x - h
  119.     IF d = 3 THEN y = y + h
  120.     IF d = 4 THEN y = y - h
  121.     IF x > 800 - h OR x < h OR y > 600 - h OR y < h THEN x = 400: y = 300: GOTO again:
  122.     IF POINT(x, y) = _RGB32(col1, col2, col3) THEN GOTO again:
  123.     LINE (oldx, oldy)-(x, y), _RGB32(col1, col2, col3)
  124. t = 0
  125. FOR tt = 1 TO INT(1000 / h)
  126.     'randomize timer
  127.     x2 = INT(RND * 800) + 1
  128.     y2 = INT(RND * 600) + 1
  129.     d2 = INT(RND * 2) + 1
  130.     IF d2 = 1 THEN LINE (x2, y2)-(x2 + h, y2 + h), _RGB32(0, 0, 0), BF
  131.     IF d2 = 2 THEN LINE (x2, y2)-(x2 + h, y2 + h), _RGB32(0, 0, 0), BF
  132. NEXT tt
  133. bg& = _NEWIMAGE(800, 600, 32)
  134. _PUTIMAGE , 0, bg&
  135.  
  136.  
  137. 'Setup the levers
  138.     levers:
  139.     'randomize timer
  140.     leverx = INT(RND * 600) + 100
  141.     levery = INT(RND * 400) + 100
  142.     'Check for walls.
  143.     FOR cx = -2 TO 7
  144.         FOR cy = -2 TO 17
  145.             IF POINT(leverx + cx, levery + cy) = _RGB32(col1, col2, col3) THEN GOTO levers:
  146.         NEXT cy
  147.     NEXT cx
  148.     'Check for other levers.
  149.     FOR cx = -2 TO 7
  150.         FOR cy = -2 TO 17
  151.             IF POINT(leverx + cx, levery + cy) = _RGB32(22, 255, 122) THEN GOTO levers:
  152.         NEXT cy
  153.     NEXT cx
  154.     LINE (leverx, levery)-(leverx + 5, levery + 15), _RGB32(22, 255, 122), BF
  155.     lev = lev + 1
  156.     leverx(lev) = leverx: levery(lev) = levery
  157.     IF lev = 5 THEN EXIT DO
  158.  
  159. 'Setup the candy.
  160.     candy:
  161.     'randomize timer
  162.     candyx = INT(RND * 600) + 100
  163.     candyy = INT(RND * 400) + 100
  164.     'Check for walls.
  165.     FOR cx = -7 TO 7
  166.         FOR cy = -7 TO 7
  167.             IF POINT(candyx + cx, candyy + cy) = _RGB32(col1, col2, col3) THEN GOTO candy:
  168.         NEXT cy
  169.     NEXT cx
  170.     'Check for other candy.
  171.     FOR cx = -7 TO 7
  172.         FOR cy = -7 TO 7
  173.             IF POINT(candyx + cx, candyy + cy) = _RGB32(255, 161, 0) THEN GOTO candy:
  174.         NEXT cy
  175.     NEXT cx
  176.     'Check for levers.
  177.     FOR cx = -2 TO 7
  178.         FOR cy = -2 TO 17
  179.             IF POINT(candyx + cx, candyy + cy) = _RGB32(22, 255, 122) THEN GOTO candy:
  180.         NEXT cy
  181.     NEXT cx
  182.     CIRCLE (candyx, candyy), 4, _RGB32(255, 161, 0)
  183.     PAINT (candyx, candyy), _RGB32(255, 161, 0)
  184.     c = c + 1
  185.     candyx(c) = candyx: candyy(c) = candyy
  186.     IF c = 150 THEN EXIT DO
  187. 'You are coords xx and yy.
  188. xx = 400
  189. yy = 594
  190. _TITLE "Arrow Keys To Move, Esc or Q To Quit."
  191.  
  192. 'The Main Loop
  193.     _LIMIT 200
  194.     CLS
  195.     _PUTIMAGE , bg&, 0
  196.     FOR i = 1 TO 150
  197.         CIRCLE (candyx(i), candyy(i)), 3, &HFFFFFF00
  198.         PAINT (candyx(i), candyy(i)), &HFFFFFF00, &HFFFFFF00
  199.     NEXT
  200.     FOR i = 1 TO 5
  201.         LINE (leverx(i), levery(i))-(leverx(i) + 5, levery(i) + 15), _RGB32(22, 255, 122), BF
  202.     NEXT
  203.     xx = _MOUSEX: yy = _MOUSEY
  204.     a$ = INKEY$
  205.     IF a$ = CHR$(0) + CHR$(72) THEN
  206.         dry = -1
  207.         drx = 0
  208.     END IF
  209.     IF a$ = CHR$(0) + CHR$(80) THEN
  210.         dry = 1
  211.         drx = 0
  212.     END IF
  213.     IF a$ = CHR$(0) + CHR$(77) THEN
  214.         drx = 1
  215.         dry = 0
  216.     END IF
  217.     IF a$ = CHR$(0) + CHR$(75) THEN
  218.         drx = -1
  219.         dry = 0
  220.     END IF
  221.     IF a$ = CHR$(27) THEN END
  222.     IF a$ = "q" OR a$ = "Q" THEN END
  223.     GOSUB you:
  224.     GOSUB candy2:
  225.     GOSUB lev:
  226.     GOSUB circles:
  227.  
  228. lev:
  229.  
  230. FOR wy = -15 TO INT(h / 3) + 15
  231.     FOR wx = -15 TO INT(h / 3) + 15
  232.         IF POINT(xx + wx, yy + wy) = _RGB32(22, 255, 122) THEN
  233.             GOTO deletelever:
  234.         END IF
  235.     NEXT wx
  236. NEXT wy
  237.  
  238. 'Check the area around you to delete the lever.
  239. deletelever:
  240.  
  241. FOR wyy = -5 TO INT(h / 3) + 15
  242.     FOR wxx = -5 TO INT(h / 3) + 5
  243.         IF POINT(xx + wxx, yy + wyy) = _RGB32(22, 255, 122) THEN
  244.             FOR cc = 1 TO lev
  245.                 IF xx + wxx = leverx(cc) AND yy + wyy = levery(cc) THEN
  246.                     LINE (leverx(cc), levery(cc))-(leverx(cc) + 5, levery(cc) + 15), _RGB32(0, 0, 0), BF
  247.                     FOR snd = 450 TO 550 STEP 25
  248.                         SOUND snd, .15
  249.                     NEXT snd
  250.                     rr = 0
  251.                     lv = 1
  252.                     levers = levers - 1
  253.                     IF levers < 0 THEN levers = 0
  254.                     LOCATE 1, 25: PRINT "Levers Left: "; levers
  255.                     oldsecond = TIMER
  256.                 END IF
  257.             NEXT cc
  258.         END IF
  259.     NEXT wxx
  260. NEXT wyy
  261.  
  262. 'The Random Red Bombs
  263. circles:
  264.  
  265. IF lv = 1 THEN
  266.     second = TIMER
  267.     IF second - oldsecond > 20 THEN lv = 0: slv = 0: GOTO nexone:
  268.     IF slv = 1 THEN RETURN
  269.     CIRCLE (lx, ly), 15, _RGB32(0, 0, 0)
  270.     CIRCLE (lx2, ly2), 15, _RGB32(0, 0, 0)
  271.     CIRCLE (lx3, ly3), 15, _RGB32(0, 0, 0)
  272.     CIRCLE (lx4, ly4), 15, _RGB32(0, 0, 0)
  273.     slv = 1
  274.     RETURN
  275. nexone:
  276.  
  277. IF rr = 1 THEN GOTO skip:
  278. 'randomize timer
  279. rl = INT(RND * 1000) + 1
  280. IF rl > 975 AND rr = 0 THEN
  281.     'randomize timer
  282.     lx = INT(RND * 750) + 1
  283.     ly = INT(RND * 500) + 1
  284.     lx2 = INT(RND * 750) + 1
  285.     ly2 = INT(RND * 500) + 1
  286.     lx3 = INT(RND * 750) + 1
  287.     ly3 = INT(RND * 500) + 1
  288.     lx4 = INT(RND * 750) + 1
  289.     ly4 = INT(RND * 500) + 1
  290.     rr = 1
  291. IF rr = 0 THEN RETURN
  292. skip:
  293.  
  294. IF bombs = 1 THEN GOTO skip2:
  295. CIRCLE (lx, ly), 15, _RGB32(255, 0, 0)
  296. CIRCLE (lx2, ly2), 15, _RGB32(255, 0, 0)
  297. CIRCLE (lx3, ly3), 15, _RGB32(255, 0, 0)
  298. CIRCLE (lx4, ly4), 15, _RGB32(255, 0, 0)
  299. bombs = 1
  300. skip2:
  301.  
  302. IF xx > lx - h / 3 AND xx < lx + h / 3 AND yy > ly - h / 3 AND yy < ly + h / 3 THEN GOSUB KABOOM:
  303. IF xx > lx2 - h / 3 AND xx < lx2 + h / 3 AND yy > ly2 - h / 3 AND yy < ly2 + h / 3 THEN GOSUB KABOOM:
  304. IF xx > lx3 - h / 3 AND xx < lx3 + h / 3 AND yy > ly3 - h / 3 AND yy < ly3 + h / 3 THEN GOSUB KABOOM:
  305. IF xx > lx4 - h / 3 AND xx < lx4 + h / 3 AND yy > ly4 - h / 3 AND yy < ly4 + h / 3 THEN GOSUB KABOOM:
  306. 'randomize timer
  307. rl2 = INT(RND * 10000) + 1
  308. IF rl2 > 9985 THEN
  309.     rr = 0
  310.     bombs = 0
  311.     CIRCLE (lx, ly), 15, _RGB32(0, 0, 0)
  312.     CIRCLE (lx2, ly2), 15, _RGB32(0, 0, 0)
  313.     CIRCLE (lx3, ly3), 15, _RGB32(0, 0, 0)
  314.     CIRCLE (lx4, ly4), 15, _RGB32(0, 0, 0)
  315.  
  316. KABOOM:
  317. players = players - 1
  318. LINE (xx, yy)-(xx + INT(h / 3), yy + INT(h / 3)), _RGB32(0, 0, 0), BF
  319. CIRCLE (lx, ly), 15, _RGB32(0, 0, 0)
  320. CIRCLE (lx2, ly2), 15, _RGB32(0, 0, 0)
  321. CIRCLE (lx3, ly3), 15, _RGB32(0, 0, 0)
  322. CIRCLE (lx4, ly4), 15, _RGB32(0, 0, 0)
  323. FOR sz = 1 TO 10
  324.     CIRCLE (xx + (h / 3), yy + (h / 3)), sz, _RGB32(255, 0, 0)
  325.     SOUND 100, .25
  326.     _DELAY .1
  327. NEXT sz
  328. FOR sz = 1 TO 10 STEP .25
  329.     CIRCLE (xx + (h / 3), yy + (h / 3)), sz, _RGB32(0, 0, 0)
  330.     _DELAY .01
  331. NEXT sz
  332. xx = 400
  333. yy = 594
  334. rr = 0
  335. slv = 0
  336. bombs = 0
  337. players$ = STR$(players)
  338. _TITLE "Score: " + sc$ + "    Players: " + players$ + "   Level: " + level$ + "       Arrow Keys To Move, Esc or Q To Quit."
  339. IF players = 0 THEN
  340.     LOCATE 15, 45: PRINT "G A M E   O V E R"
  341.     LOCATE 17, 45: INPUT "Again(Y/N)"; ag$
  342.     IF LEFT$(ag$, 1) = "y" OR LEFT$(ag$, 1) = "Y" THEN CLEAR: GOTO begin:
  343.     END
  344.  
  345. 'Check to see if you got a candy.
  346. candy2:
  347.  
  348. FOR wy = -5 TO INT(h / 2) + 5
  349.     FOR wx = -5 TO INT(h / 2) + 5
  350.         IF POINT(xx + wx, yy + wy) = _RGB32(255, 161, 0) THEN
  351.             sc = sc + 10
  352.             sc$ = STR$(sc)
  353.             players$ = STR$(players)
  354.             _TITLE "Score: " + sc$ + "    Players: " + players$ + "   Level: " + level$ + "       Arrow Keys To Move, Esc or Q To Quit."
  355.             GOTO deletecandy:
  356.         END IF
  357.     NEXT wx
  358. NEXT wy
  359.  
  360. 'Check the area around you to delete the candy.
  361. deletecandy:
  362.  
  363. FOR wyy = -5 TO INT(h / 3) + 5
  364.     FOR wxx = -5 TO INT(h / 3) + 5
  365.         IF POINT(xx + wxx, yy + wyy) = _RGB32(255, 161, 0) THEN
  366.             FOR cc = 1 TO c
  367.                 IF xx + wxx = candyx(cc) AND yy + wyy = candyy(cc) THEN
  368.                     CIRCLE (candyx(cc), candyy(cc)), 4, _RGB32(0, 0, 0)
  369.                     PAINT (candyx(cc), candyy(cc)), _RGB32(0, 0, 0)
  370.                     SOUND 100, .5
  371.                     co = co + 1
  372.                     co2 = 100 - co
  373.                     IF co2 < 0 THEN co2 = 0
  374.                     LOCATE 1, 1: PRINT "Candy To Get: "; co2
  375.                     mouth = 1
  376.                     oldmsec = TIMER
  377.                 END IF
  378.             NEXT cc
  379.         END IF
  380.     NEXT wxx
  381. NEXT wyy
  382. IF co2 = 0 AND levers = 0 THEN
  383.     level = level + 1
  384.     co = 0
  385.     level$ = STR$(level)
  386.     _TITLE "Score: " + sc$ + "   Level: " + level$ + "       Arrow Keys To Move, Esc or Q To Quit."
  387.     GOTO level:
  388.  
  389. you:
  390.  
  391. oldxx = xx
  392. oldyy = yy
  393. xx = xx + drx
  394. yy = yy + dry
  395.  
  396. IF xx < 5 THEN xx = 5
  397. IF xx > 795 THEN xx = 795
  398. IF yy < 15 THEN yy = 15
  399. IF yy > 595 THEN yy = 595
  400.  
  401. 'Check to see if you hit the walls.
  402. FOR wx = -1 TO INT(h / 3)
  403.     FOR wy = -1 TO INT(h / 3)
  404.         IF POINT(xx + wx, yy + wy) = _RGB32(col1, col2, col3) THEN
  405.             yy = oldyy: xx = oldxx
  406.             RETURN
  407.         END IF
  408.     NEXT wy
  409. NEXT wx
  410.  
  411. 'Erase and draw you.
  412. LINE (oldxx, oldyy)-(oldxx + INT(h / 3), oldyy + INT(h / 3)), _RGB32(0, 0, 0), BF
  413. LINE (xx, yy)-(xx + INT(h / 3), yy + INT(h / 3)), _RGB32(0, 255, 0), BF
  414. LINE (xx, yy)-(xx + INT(h / 3), yy + 3), _RGB32(139, 116, 105), BF
  415.  
  416. ex1 = (xx + (INT(h / 3) / 2) / 2)
  417. ex2 = (xx + (INT(h / 3) / 2) / .65)
  418. ey = (yy + (INT(h / 3) / 2) / 2)
  419. mx = (xx + (INT(h / 3) / 2))
  420. my = (yy + (INT(h / 2.2) / 2))
  421. ny = (yy + (h / 2.85) / 2)
  422.  
  423. FOR sz = .25 TO 2 STEP .25
  424.     CIRCLE (ex1, ey), sz, _RGB32(0, 127, 255)
  425.     CIRCLE (ex2, ey), sz, _RGB32(0, 127, 255)
  426. NEXT sz
  427. FOR sz = .25 TO 2.5 STEP .25
  428.     CIRCLE (mx, my), sz, _RGB32(0, 0, 0)
  429. NEXT sz
  430.  
  431. IF mouth = 1 THEN
  432.     FOR sz = .25 TO 2.5 STEP .25
  433.         CIRCLE (mx, my), sz, _RGB32(254, 254, 254)
  434.     NEXT sz
  435.     msec = TIMER
  436.     IF msec - oldmsec > .25 THEN mouth = 0
  437.  
  438. FOR sz = .25 TO 1.5 STEP .25
  439.     CIRCLE (mx, ny), sz, _RGB32(127, 128, 127)
  440. NEXT sz
  441. 'IF h > 74 THEN dl = .003
  442. 'IF h <= 74 AND h >= 55 THEN dl = .004
  443. 'IF h < 55 THEN dl = .005
  444. '_DELAY dl
  445.  
  446.  
  447.  

Maybe we can still do collision detection with point but detecting proximity with x, y places to candy, levers or bombs is cake! But the walls might be tricky... have to sleep on that one, good night. :)
« Last Edit: August 30, 2019, 12:26:45 am by bplus »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Search-Man Game
« Reply #11 on: August 30, 2019, 12:28:11 am »
OK, I will in a minute. But I just found a glitch in mine LOL. Sometimes when your guy gets close to a candy, even on the other side of a wall, your score keeps going and going non-stop. LOL So I moved the scoring to where the candy is deleted instead of where it was detected.
There's another thing I want to try and fix too if I can. It's how if the bombs appear on you and kill you, you never see any of the bombs at all. Might look into that some.
Here is the update:

Code: QB64: [Select]
  1. _TITLE "Search-Man"
  2. SCREEN _NEWIMAGE(800, 600, 32)
  3. _LIMIT 3000
  4. xx = 350: yy = 300: h = 200
  5. splashscreen:
  6. LINE (xx, yy)-(xx + INT(h / 3), yy + INT(h / 3)), _RGB32(0, 255, 0), BF
  7. LINE (xx, yy)-(xx + INT(h / 3), yy + 3), _RGB32(139, 116, 105), BF
  8. ex1 = (xx + (INT(h / 3) / 2) / 2)
  9. ex2 = (xx + (INT(h / 3) / 2) / .65)
  10. ey = (yy + (INT(h / 3) / 2) / 2)
  11. mx = (xx + (INT(h / 3) / 2))
  12. my = (yy + (INT(h / 2.2) / 2))
  13. ny = (yy + (h / 2.85) / 2)
  14. FOR sz = .25 TO 2 STEP .25
  15.     CIRCLE (ex1, ey), sz, _RGB32(0, 127, 255)
  16.     CIRCLE (ex2, ey), sz, _RGB32(0, 127, 255)
  17. NEXT sz
  18. FOR sz = .25 TO 2.5 STEP .25
  19.     CIRCLE (mx, my), sz, _RGB32(0, 0, 0)
  20. NEXT sz
  21. FOR sz = .25 TO 1.5 STEP .25
  22.     CIRCLE (mx, ny), sz, _RGB32(0, 0, 0)
  23. NEXT sz
  24. mouth:
  25. m = m + 1
  26. IF m > 9 THEN GOTO begin:
  27. IF m = 1 THEN mouth = 0
  28. IF m = 2 THEN mouth = 1
  29. IF m = 3 THEN mouth = 0
  30. IF m = 4 THEN mouth = 1
  31. IF m = 5 THEN mouth = 0
  32. IF m = 6 THEN mouth = 1
  33. IF m = 7 THEN mouth = 0
  34. IF m = 8 THEN mouth = 1
  35. IF m = 9 THEN mouth = 0
  36. IF mouth = 1 THEN
  37.     FOR sz = .25 TO 2.5 STEP .25
  38.         CIRCLE (mx, my), sz, _RGB32(254, 254, 254)
  39.     NEXT sz
  40. IF mouth = 0 THEN
  41.     FOR sz = .25 TO 1.5 STEP .25
  42.         CIRCLE (mx, my), sz, _RGB32(0, 0, 0)
  43.     NEXT sz
  44. GOTO mouth:
  45. begin:
  46. PRINT "                                     Search-Man"
  47. PRINT "                                     by  Ken G."
  48. PRINT "                - Use the arrow keys to guide your green guy around the maze"
  49. PRINT "                  to eat the orange candy."
  50. PRINT "                - Levels change when 100 candies have been eaten and all 5"
  51. PRINT "                  green levers have been used."
  52. PRINT "                - Avoid hitting the randomly placed red bombs."
  53. PRINT "                - The green levers will delete the bombs for 20 seconds."
  54. PRINT "                - You start out with 3 players."
  55. PRINT "                - Every level is different, Good Luck!"
  56. INPUT "                               Press Enter To Begin.", a$
  57. level = 1
  58. sc = 0
  59. players = 3
  60. level$ = STR$(level)
  61.  
  62. 'Start a new level here.
  63. level:
  64. DIM candyx(500), candyy(500)
  65. DIM leverx(200), levery(200)
  66. x = 400: y = 300
  67. t = 0
  68. c = 0
  69. drx = 0: dry = 0
  70. lv = 0: slv = 0: bombs = 0
  71. lev = 0
  72. levers = 5
  73. mouth = 0
  74. h = INT(RND * 60) + 40
  75.  
  76. 'Randomly choose a wall color.
  77. col = INT(RND * 8) + 1
  78. 'green
  79. IF col = 1 THEN
  80.     col1 = 33: col2 = 230: col3 = 7
  81. 'purple
  82. IF col = 2 THEN
  83.     col1 = 152: col2 = 7: col3 = 230
  84. 'yellow
  85. IF col = 3 THEN
  86.     col1 = 247: col2 = 255: col3 = 8
  87. 'orange
  88. IF col = 4 THEN
  89.     col1 = 255: col2 = 156: col3 = 8
  90. 'red
  91. IF col = 5 THEN
  92.     col1 = 255: col2 = 8: col3 = 8
  93. 'blue
  94. IF col = 6 THEN
  95.     col1 = 8: col2 = 131: col3 = 255
  96. 'white
  97. IF col = 7 THEN
  98.     col1 = 255: col2 = 255: col3 = 255
  99. 'greenish-blue
  100. IF col = 8 THEN
  101.     col1 = 10: col2 = 240: col3 = 201
  102.  
  103. 'Make the walls.
  104.     _LIMIT 3000
  105.     again:
  106.     t = t + 1
  107.     IF t = 30000000 THEN EXIT DO
  108.     oldx = x
  109.     oldy = y
  110.     oldd = d
  111.     d = INT(RND * 4) + 1
  112.     IF d = oldd THEN GOTO again:
  113.     IF d = 1 THEN x = x + h
  114.     IF d = 2 THEN x = x - h
  115.     IF d = 3 THEN y = y + h
  116.     IF d = 4 THEN y = y - h
  117.     IF x > 800 - h OR x < h OR y > 600 - h OR y < h THEN x = 400: y = 300: GOTO again:
  118.     IF POINT(x, y) = _RGB32(col1, col2, col3) THEN GOTO again:
  119.     LINE (oldx, oldy)-(x, y), _RGB32(col1, col2, col3)
  120. t = 0
  121. FOR tt = 1 TO INT(1000 / h)
  122.     x2 = INT(RND * 800) + 1
  123.     y2 = INT(RND * 600) + 1
  124.     d2 = INT(RND * 2) + 1
  125.     IF d2 = 1 THEN LINE (x2, y2)-(x2 + h, y2 + h), _RGB32(0, 0, 0), BF
  126.     IF d2 = 2 THEN LINE (x2, y2)-(x2 + h, y2 + h), _RGB32(0, 0, 0), BF
  127. NEXT tt
  128.  
  129. 'Setup the levers
  130.     levers:
  131.     leverx = INT(RND * 600) + 100
  132.     levery = INT(RND * 400) + 100
  133.     'Check for walls.
  134.     FOR cx = -2 TO 7
  135.         FOR cy = -2 TO 17
  136.             IF POINT(leverx + cx, levery + cy) = _RGB32(col1, col2, col3) THEN GOTO levers:
  137.         NEXT cy
  138.     NEXT cx
  139.     'Check for other levers.
  140.     FOR cx = -2 TO 7
  141.         FOR cy = -2 TO 17
  142.             IF POINT(leverx + cx, levery + cy) = _RGB32(22, 255, 122) THEN GOTO levers:
  143.         NEXT cy
  144.     NEXT cx
  145.     LINE (leverx, levery)-(leverx + 5, levery + 15), _RGB32(22, 255, 122), BF
  146.     lev = lev + 1
  147.     leverx(lev) = leverx: levery(lev) = levery
  148.     IF lev = 5 THEN EXIT DO
  149.  
  150. 'Setup the candy.
  151.     candy:
  152.     candyx = INT(RND * 600) + 100
  153.     candyy = INT(RND * 400) + 100
  154.     'Check for walls.
  155.     FOR cx = -7 TO 7
  156.         FOR cy = -7 TO 7
  157.             IF POINT(candyx + cx, candyy + cy) = _RGB32(col1, col2, col3) THEN GOTO candy:
  158.         NEXT cy
  159.     NEXT cx
  160.     'Check for other candy.
  161.     FOR cx = -7 TO 7
  162.         FOR cy = -7 TO 7
  163.             IF POINT(candyx + cx, candyy + cy) = _RGB32(255, 161, 0) THEN GOTO candy:
  164.         NEXT cy
  165.     NEXT cx
  166.     'Check for levers.
  167.     FOR cx = -2 TO 7
  168.         FOR cy = -2 TO 17
  169.             IF POINT(candyx + cx, candyy + cy) = _RGB32(22, 255, 122) THEN GOTO candy:
  170.         NEXT cy
  171.     NEXT cx
  172.     CIRCLE (candyx, candyy), 4, _RGB32(255, 161, 0)
  173.     PAINT (candyx, candyy), _RGB32(255, 161, 0)
  174.     c = c + 1
  175.     candyx(c) = candyx: candyy(c) = candyy
  176.     IF c = 150 THEN EXIT DO
  177.  
  178. 'You are coords xx and yy.
  179. xx = 400
  180. yy = 594
  181. _TITLE "Arrow Keys To Move, Esc or Q To Quit."
  182.  
  183. 'The Main Loop
  184.     _LIMIT 3000
  185.     a$ = INKEY$
  186.     IF a$ = CHR$(0) + CHR$(72) THEN
  187.         dry = -1
  188.         drx = 0
  189.     END IF
  190.     IF a$ = CHR$(0) + CHR$(80) THEN
  191.         dry = 1
  192.         drx = 0
  193.     END IF
  194.     IF a$ = CHR$(0) + CHR$(77) THEN
  195.         drx = 1
  196.         dry = 0
  197.     END IF
  198.     IF a$ = CHR$(0) + CHR$(75) THEN
  199.         drx = -1
  200.         dry = 0
  201.     END IF
  202.     IF a$ = CHR$(27) THEN END
  203.     IF a$ = "q" OR a$ = "Q" THEN END
  204.     GOSUB you:
  205.     GOSUB candy2:
  206.     GOSUB lev:
  207.     GOSUB circles:
  208.  
  209. lev:
  210. _LIMIT 3000
  211. FOR wy = -15 TO INT(h / 3) + 15
  212.     FOR wx = -15 TO INT(h / 3) + 15
  213.         IF POINT(xx + wx, yy + wy) = _RGB32(22, 255, 122) THEN
  214.             GOTO deletelever:
  215.         END IF
  216.     NEXT wx
  217. NEXT wy
  218.  
  219. 'Check the area around you to delete the lever.
  220. deletelever:
  221. _LIMIT 3000
  222. FOR wyy = -5 TO INT(h / 3) + 15
  223.     FOR wxx = -5 TO INT(h / 3) + 5
  224.         IF POINT(xx + wxx, yy + wyy) = _RGB32(22, 255, 122) THEN
  225.             FOR cc = 1 TO lev
  226.                 IF xx + wxx = leverx(cc) AND yy + wyy = levery(cc) THEN
  227.                     LINE (leverx(cc), levery(cc))-(leverx(cc) + 5, levery(cc) + 15), _RGB32(0, 0, 0), BF
  228.                     FOR snd = 450 TO 550 STEP 25
  229.                         SOUND snd, .15
  230.                     NEXT snd
  231.                     rr = 0
  232.                     lv = 1
  233.                     levers = levers - 1
  234.                     IF levers < 0 THEN levers = 0
  235.                     LOCATE 1, 25: PRINT "Levers Left: "; levers
  236.                     oldsecond = TIMER
  237.                 END IF
  238.             NEXT cc
  239.         END IF
  240.     NEXT wxx
  241. NEXT wyy
  242.  
  243. 'The Random Red Bombs
  244. circles:
  245. _LIMIT 3000
  246. IF lv = 1 THEN
  247.     second = TIMER
  248.     IF second - oldsecond > 20 THEN lv = 0: slv = 0: GOTO nexone:
  249.     IF slv = 1 THEN RETURN
  250.     CIRCLE (lx, ly), 15, _RGB32(0, 0, 0)
  251.     CIRCLE (lx2, ly2), 15, _RGB32(0, 0, 0)
  252.     CIRCLE (lx3, ly3), 15, _RGB32(0, 0, 0)
  253.     CIRCLE (lx4, ly4), 15, _RGB32(0, 0, 0)
  254.     slv = 1
  255.     RETURN
  256. nexone:
  257. _LIMIT 3000
  258. IF rr = 1 THEN GOTO skip:
  259. rl = INT(RND * 1000) + 1
  260. IF rl > 975 AND rr = 0 THEN
  261.     lx = INT(RND * 750) + 1
  262.     ly = INT(RND * 500) + 1
  263.     lx2 = INT(RND * 750) + 1
  264.     ly2 = INT(RND * 500) + 1
  265.     lx3 = INT(RND * 750) + 1
  266.     ly3 = INT(RND * 500) + 1
  267.     lx4 = INT(RND * 750) + 1
  268.     ly4 = INT(RND * 500) + 1
  269.     rr = 1
  270. IF rr = 0 THEN RETURN
  271. skip:
  272. _LIMIT 3000
  273. IF bombs = 1 THEN GOTO skip2:
  274. CIRCLE (lx, ly), 15, _RGB32(255, 0, 0)
  275. CIRCLE (lx2, ly2), 15, _RGB32(255, 0, 0)
  276. CIRCLE (lx3, ly3), 15, _RGB32(255, 0, 0)
  277. CIRCLE (lx4, ly4), 15, _RGB32(255, 0, 0)
  278. bombs = 1
  279. skip2:
  280. _LIMIT 3000
  281. IF xx > lx - h / 3 AND xx < lx + h / 3 AND yy > ly - h / 3 AND yy < ly + h / 3 THEN GOSUB KABOOM:
  282. IF xx > lx2 - h / 3 AND xx < lx2 + h / 3 AND yy > ly2 - h / 3 AND yy < ly2 + h / 3 THEN GOSUB KABOOM:
  283. IF xx > lx3 - h / 3 AND xx < lx3 + h / 3 AND yy > ly3 - h / 3 AND yy < ly3 + h / 3 THEN GOSUB KABOOM:
  284. IF xx > lx4 - h / 3 AND xx < lx4 + h / 3 AND yy > ly4 - h / 3 AND yy < ly4 + h / 3 THEN GOSUB KABOOM:
  285. rl2 = INT(RND * 10000) + 1
  286. IF rl2 > 9985 THEN
  287.     rr = 0
  288.     bombs = 0
  289.     CIRCLE (lx, ly), 15, _RGB32(0, 0, 0)
  290.     CIRCLE (lx2, ly2), 15, _RGB32(0, 0, 0)
  291.     CIRCLE (lx3, ly3), 15, _RGB32(0, 0, 0)
  292.     CIRCLE (lx4, ly4), 15, _RGB32(0, 0, 0)
  293.  
  294. KABOOM:
  295. players = players - 1
  296. LINE (xx, yy)-(xx + INT(h / 3), yy + INT(h / 3)), _RGB32(0, 0, 0), BF
  297. CIRCLE (lx, ly), 15, _RGB32(0, 0, 0)
  298. CIRCLE (lx2, ly2), 15, _RGB32(0, 0, 0)
  299. CIRCLE (lx3, ly3), 15, _RGB32(0, 0, 0)
  300. CIRCLE (lx4, ly4), 15, _RGB32(0, 0, 0)
  301. FOR sz = 1 TO 10
  302.     CIRCLE (xx + (h / 3), yy + (h / 3)), sz, _RGB32(255, 0, 0)
  303.     SOUND 100, .25
  304.     _DELAY .1
  305. NEXT sz
  306. FOR sz = 1 TO 10 STEP .25
  307.     CIRCLE (xx + (h / 3), yy + (h / 3)), sz, _RGB32(0, 0, 0)
  308.     _DELAY .01
  309. NEXT sz
  310. xx = 400
  311. yy = 594
  312. rr = 0
  313. slv = 0
  314. bombs = 0
  315. players$ = STR$(players)
  316. _TITLE "Score: " + sc$ + "    Players: " + players$ + "   Level: " + level$ + "       Arrow Keys To Move, Esc or Q To Quit."
  317. IF players = 0 THEN
  318.     LOCATE 15, 45: PRINT "G A M E   O V E R"
  319.     LOCATE 17, 45: INPUT "Again(Y/N)"; ag$
  320.     IF LEFT$(ag$, 1) = "y" OR LEFT$(ag$, 1) = "Y" THEN CLEAR: GOTO begin:
  321.     END
  322.  
  323. 'Check to see if you got a candy.
  324. candy2:
  325. _LIMIT 3000
  326. FOR wy = -5 TO INT(h / 2) + 5
  327.     FOR wx = -5 TO INT(h / 2) + 5
  328.         IF POINT(xx + wx, yy + wy) = _RGB32(255, 161, 0) THEN
  329.             GOTO deletecandy:
  330.         END IF
  331.     NEXT wx
  332. NEXT wy
  333.  
  334. 'Check the area around you to delete the candy.
  335. deletecandy:
  336. _LIMIT 3000
  337. FOR wyy = -5 TO INT(h / 3) + 5
  338.     FOR wxx = -5 TO INT(h / 3) + 5
  339.         IF POINT(xx + wxx, yy + wyy) = _RGB32(255, 161, 0) THEN
  340.             FOR cc = 1 TO c
  341.                 IF xx + wxx = candyx(cc) AND yy + wyy = candyy(cc) THEN
  342.                     CIRCLE (candyx(cc), candyy(cc)), 4, _RGB32(0, 0, 0)
  343.                     PAINT (candyx(cc), candyy(cc)), _RGB32(0, 0, 0)
  344.                     SOUND 100, .5
  345.                     co = co + 1
  346.                     co2 = 100 - co
  347.                     IF co2 < 0 THEN co2 = 0
  348.                     LOCATE 1, 1: PRINT "Candy To Get: "; co2
  349.                     mouth = 1
  350.                     oldmsec = TIMER
  351.                     sc = sc + 10
  352.                     sc$ = STR$(sc)
  353.                     players$ = STR$(players)
  354.                     _TITLE "Score: " + sc$ + "    Players: " + players$ + "   Level: " + level$ + "       Arrow Keys To Move, Esc or Q To Quit."
  355.                 END IF
  356.             NEXT cc
  357.         END IF
  358.     NEXT wxx
  359. NEXT wyy
  360. IF co2 = 0 AND levers = 0 THEN
  361.     level = level + 1
  362.     co = 0
  363.     level$ = STR$(level)
  364.     _TITLE "Score: " + sc$ + "   Level: " + level$ + "       Arrow Keys To Move, Esc or Q To Quit."
  365.     GOTO level:
  366.  
  367. you:
  368. _LIMIT 3000
  369. oldxx = xx
  370. oldyy = yy
  371. xx = xx + drx
  372. yy = yy + dry
  373.  
  374. IF xx < 5 THEN xx = 5
  375. IF xx > 795 THEN xx = 795
  376. IF yy < 15 THEN yy = 15
  377. IF yy > 595 THEN yy = 595
  378.  
  379. 'Check to see if you hit the walls.
  380. FOR wx = -1 TO INT(h / 3)
  381.     FOR wy = -1 TO INT(h / 3)
  382.         IF POINT(xx + wx, yy + wy) = _RGB32(col1, col2, col3) THEN
  383.             yy = oldyy: xx = oldxx
  384.             RETURN
  385.         END IF
  386.     NEXT wy
  387. NEXT wx
  388.  
  389. 'Erase and draw you.
  390. LINE (oldxx, oldyy)-(oldxx + INT(h / 3), oldyy + INT(h / 3)), _RGB32(0, 0, 0), BF
  391. LINE (xx, yy)-(xx + INT(h / 3), yy + INT(h / 3)), _RGB32(0, 255, 0), BF
  392. LINE (xx, yy)-(xx + INT(h / 3), yy + 3), _RGB32(139, 116, 105), BF
  393.  
  394. ex1 = (xx + (INT(h / 3) / 2) / 2)
  395. ex2 = (xx + (INT(h / 3) / 2) / .65)
  396. ey = (yy + (INT(h / 3) / 2) / 2)
  397. mx = (xx + (INT(h / 3) / 2))
  398. my = (yy + (INT(h / 2.2) / 2))
  399. ny = (yy + (h / 2.85) / 2)
  400.  
  401. FOR sz = .25 TO 2 STEP .25
  402.     CIRCLE (ex1, ey), sz, _RGB32(0, 127, 255)
  403.     CIRCLE (ex2, ey), sz, _RGB32(0, 127, 255)
  404. NEXT sz
  405. IF mouth = 1 THEN GOTO skip3:
  406. CIRCLE (mx, my), 2.5, _RGB32(0, 0, 0)
  407. PAINT (mx, my), _RGB32(0, 0, 0)
  408. skip3:
  409. IF mouth = 1 THEN
  410.     CIRCLE (mx, my), 2.5, _RGB32(254, 254, 254)
  411.     PAINT (mx, my), _RGB32(254, 254, 254)
  412.     msec = TIMER
  413.     IF msec - oldmsec > .25 THEN mouth = 0
  414.  
  415. CIRCLE (mx, ny), 1.5, _RGB32(127, 128, 127)
  416. PAINT (mx, ny), _RGB32(127, 128, 127)
  417.  
  418. IF h > 74 THEN dl = .003
  419. IF h <= 74 AND h >= 55 THEN dl = .004
  420. IF h < 55 THEN dl = .005
  421.  
  422.  

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Search-Man Game
« Reply #12 on: August 30, 2019, 12:33:17 am »
It might be because I use a fast mouse setting in Windows 10, but when I tried yours, it doesn't detect or delete the candy. And when it goes over a lever, it doesn't delete those either so it rings and rings at you on the speakers since it is still there. hehe Neat concept though. But my mouse is just way too fast. It is so fast that it bounces through the walls. It hints they are there, but the mouse overtakes it and hops over them. :) Neat to see it with a mouse though.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Search-Man Game
« Reply #13 on: August 30, 2019, 12:45:08 am »
It doesn't eat candy because I am not that far. You must realize, I erase everything and redraw everything on each loop. I haven't gotten that far with candy and lever collisions yet, I have to detect collision and then track what remains to be drawn the next loop.

It was just demo to show easy it is to get around the maze with a mouse.




Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Search-Man Game
« Reply #14 on: August 30, 2019, 01:30:15 am »
Ah OK, I figured it was something like that.
Over here on my version I cleaned it up a lot by erasing all of the loops that fill circles and instead using CIRCLE and PAINT. That includes your guy and also the opening splash screen. On the splash screen I also deleted all the lines that said when to open and shut his mouth and instead used a MOD (I think for the first time LOL). So here is my update:
Oh also, I doubt the mouse version will be my final version for my website (unless I decide to put both on there). Maybe because I'm an old school 80's gamer, I feel more in touch with the game using keys. But we'll see. I can see some fun with both of them.

Code: QB64: [Select]
  1. _TITLE "Search-Man"
  2. SCREEN _NEWIMAGE(800, 600, 32)
  3. _LIMIT 3000
  4. xx = 350: yy = 300: h = 200
  5. splashscreen:
  6. LINE (xx, yy)-(xx + INT(h / 3), yy + INT(h / 3)), _RGB32(0, 255, 0), BF
  7. LINE (xx, yy)-(xx + INT(h / 3), yy + 3), _RGB32(139, 116, 105), BF
  8. ex1 = (xx + (INT(h / 3) / 2) / 2)
  9. ex2 = (xx + (INT(h / 3) / 2) / .65)
  10. ey = (yy + (INT(h / 3) / 2) / 2)
  11. mx = (xx + (INT(h / 3) / 2))
  12. my = (yy + (INT(h / 2.2) / 2))
  13. ny = (yy + (h / 2.85) / 2)
  14. CIRCLE (ex1, ey), 2, _RGB32(0, 127, 255)
  15. PAINT (ex1, ey), _RGB32(0, 127, 255)
  16. CIRCLE (ex2, ey), 2, _RGB32(0, 127, 255)
  17. PAINT (ex2, ey), _RGB32(0, 127, 255)
  18. CIRCLE (mx, ny), 1.5, _RGB32(0, 0, 0)
  19. PAINT (mx, ny), _RGB32(0, 0, 0)
  20. mouth:
  21. m = m + 1
  22. IF m MOD 2 = 1 THEN mouth = 0 ELSE mouth = 1
  23. IF m > 9 THEN GOTO begin:
  24. IF mouth = 1 THEN
  25.     CIRCLE (mx, my), 2.5, _RGB32(254, 254, 254)
  26.     PAINT (mx, my), _RGB32(254, 254, 254)
  27. IF mouth = 0 THEN
  28.     CIRCLE (mx, my), 2.5, _RGB32(0, 0, 0)
  29.     PAINT (mx, my), _RGB32(0, 0, 0)
  30. GOTO mouth:
  31. begin:
  32. PRINT "                                     Search-Man"
  33. PRINT "                                     by  Ken G."
  34. PRINT "                - Use the arrow keys to guide your green guy around the maze"
  35. PRINT "                  to eat the orange candy."
  36. PRINT "                - Levels change when 100 candies have been eaten and all 5"
  37. PRINT "                  green levers have been used."
  38. PRINT "                - Avoid hitting the randomly placed red bombs."
  39. PRINT "                - The green levers will delete the bombs for 20 seconds."
  40. PRINT "                - You start out with 3 players."
  41. PRINT "                - Every level is different, Good Luck!"
  42. INPUT "                               Press Enter To Begin.", a$
  43. level = 1
  44. sc = 0
  45. players = 3
  46. level$ = STR$(level)
  47.  
  48. 'Start a new level here.
  49. level:
  50. DIM candyx(500), candyy(500)
  51. DIM leverx(200), levery(200)
  52. x = 400: y = 300
  53. t = 0
  54. c = 0
  55. drx = 0: dry = 0
  56. lv = 0: slv = 0: bombs = 0
  57. lev = 0
  58. levers = 5
  59. mouth = 0
  60. h = INT(RND * 60) + 40
  61.  
  62. 'Randomly choose a wall color.
  63. col = INT(RND * 8) + 1
  64. 'green
  65. IF col = 1 THEN
  66.     col1 = 33: col2 = 230: col3 = 7
  67. 'purple
  68. IF col = 2 THEN
  69.     col1 = 152: col2 = 7: col3 = 230
  70. 'yellow
  71. IF col = 3 THEN
  72.     col1 = 247: col2 = 255: col3 = 8
  73. 'orange
  74. IF col = 4 THEN
  75.     col1 = 255: col2 = 156: col3 = 8
  76. 'red
  77. IF col = 5 THEN
  78.     col1 = 255: col2 = 8: col3 = 8
  79. 'blue
  80. IF col = 6 THEN
  81.     col1 = 8: col2 = 131: col3 = 255
  82. 'white
  83. IF col = 7 THEN
  84.     col1 = 255: col2 = 255: col3 = 255
  85. 'greenish-blue
  86. IF col = 8 THEN
  87.     col1 = 10: col2 = 240: col3 = 201
  88.  
  89. 'Make the walls.
  90.     _LIMIT 3000
  91.     again:
  92.     t = t + 1
  93.     IF t = 30000000 THEN EXIT DO
  94.     oldx = x
  95.     oldy = y
  96.     oldd = d
  97.     d = INT(RND * 4) + 1
  98.     IF d = oldd THEN GOTO again:
  99.     IF d = 1 THEN x = x + h
  100.     IF d = 2 THEN x = x - h
  101.     IF d = 3 THEN y = y + h
  102.     IF d = 4 THEN y = y - h
  103.     IF x > 800 - h OR x < h OR y > 600 - h OR y < h THEN x = 400: y = 300: GOTO again:
  104.     IF POINT(x, y) = _RGB32(col1, col2, col3) THEN GOTO again:
  105.     LINE (oldx, oldy)-(x, y), _RGB32(col1, col2, col3)
  106. t = 0
  107. FOR tt = 1 TO INT(1000 / h)
  108.     x2 = INT(RND * 800) + 1
  109.     y2 = INT(RND * 600) + 1
  110.     d2 = INT(RND * 2) + 1
  111.     IF d2 = 1 THEN LINE (x2, y2)-(x2 + h, y2 + h), _RGB32(0, 0, 0), BF
  112.     IF d2 = 2 THEN LINE (x2, y2)-(x2 + h, y2 + h), _RGB32(0, 0, 0), BF
  113. NEXT tt
  114.  
  115. 'Setup the levers
  116.     levers:
  117.     leverx = INT(RND * 600) + 100
  118.     levery = INT(RND * 400) + 100
  119.     'Check for walls.
  120.     FOR cx = -2 TO 7
  121.         FOR cy = -2 TO 17
  122.             IF POINT(leverx + cx, levery + cy) = _RGB32(col1, col2, col3) THEN GOTO levers:
  123.         NEXT cy
  124.     NEXT cx
  125.     'Check for other levers.
  126.     FOR cx = -2 TO 7
  127.         FOR cy = -2 TO 17
  128.             IF POINT(leverx + cx, levery + cy) = _RGB32(22, 255, 122) THEN GOTO levers:
  129.         NEXT cy
  130.     NEXT cx
  131.     LINE (leverx, levery)-(leverx + 5, levery + 15), _RGB32(22, 255, 122), BF
  132.     lev = lev + 1
  133.     leverx(lev) = leverx: levery(lev) = levery
  134.     IF lev = 5 THEN EXIT DO
  135.  
  136. 'Setup the candy.
  137.     candy:
  138.     candyx = INT(RND * 600) + 100
  139.     candyy = INT(RND * 400) + 100
  140.     'Check for walls.
  141.     FOR cx = -7 TO 7
  142.         FOR cy = -7 TO 7
  143.             IF POINT(candyx + cx, candyy + cy) = _RGB32(col1, col2, col3) THEN GOTO candy:
  144.         NEXT cy
  145.     NEXT cx
  146.     'Check for other candy.
  147.     FOR cx = -7 TO 7
  148.         FOR cy = -7 TO 7
  149.             IF POINT(candyx + cx, candyy + cy) = _RGB32(255, 161, 0) THEN GOTO candy:
  150.         NEXT cy
  151.     NEXT cx
  152.     'Check for levers.
  153.     FOR cx = -2 TO 7
  154.         FOR cy = -2 TO 17
  155.             IF POINT(candyx + cx, candyy + cy) = _RGB32(22, 255, 122) THEN GOTO candy:
  156.         NEXT cy
  157.     NEXT cx
  158.     CIRCLE (candyx, candyy), 4, _RGB32(255, 161, 0)
  159.     PAINT (candyx, candyy), _RGB32(255, 161, 0)
  160.     c = c + 1
  161.     candyx(c) = candyx: candyy(c) = candyy
  162.     IF c = 150 THEN EXIT DO
  163.  
  164. 'You are coords xx and yy.
  165. xx = 400
  166. yy = 594
  167. _TITLE "Arrow Keys To Move, Esc or Q To Quit."
  168.  
  169. 'The Main Loop
  170.     _LIMIT 3000
  171.     a$ = INKEY$
  172.     IF a$ = CHR$(0) + CHR$(72) THEN
  173.         dry = -1
  174.         drx = 0
  175.     END IF
  176.     IF a$ = CHR$(0) + CHR$(80) THEN
  177.         dry = 1
  178.         drx = 0
  179.     END IF
  180.     IF a$ = CHR$(0) + CHR$(77) THEN
  181.         drx = 1
  182.         dry = 0
  183.     END IF
  184.     IF a$ = CHR$(0) + CHR$(75) THEN
  185.         drx = -1
  186.         dry = 0
  187.     END IF
  188.     IF a$ = CHR$(27) THEN END
  189.     IF a$ = "q" OR a$ = "Q" THEN END
  190.     GOSUB you:
  191.     GOSUB candy2:
  192.     GOSUB lev:
  193.     GOSUB circles:
  194.  
  195. lev:
  196. _LIMIT 3000
  197. FOR wy = -15 TO INT(h / 3) + 15
  198.     FOR wx = -15 TO INT(h / 3) + 15
  199.         IF POINT(xx + wx, yy + wy) = _RGB32(22, 255, 122) THEN
  200.             GOTO deletelever:
  201.         END IF
  202.     NEXT wx
  203. NEXT wy
  204.  
  205. 'Check the area around you to delete the lever.
  206. deletelever:
  207. _LIMIT 3000
  208. FOR wyy = -5 TO INT(h / 3) + 15
  209.     FOR wxx = -5 TO INT(h / 3) + 5
  210.         IF POINT(xx + wxx, yy + wyy) = _RGB32(22, 255, 122) THEN
  211.             FOR cc = 1 TO lev
  212.                 IF xx + wxx = leverx(cc) AND yy + wyy = levery(cc) THEN
  213.                     LINE (leverx(cc), levery(cc))-(leverx(cc) + 5, levery(cc) + 15), _RGB32(0, 0, 0), BF
  214.                     FOR snd = 450 TO 550 STEP 25
  215.                         SOUND snd, .15
  216.                     NEXT snd
  217.                     rr = 0
  218.                     lv = 1
  219.                     levers = levers - 1
  220.                     IF levers < 0 THEN levers = 0
  221.                     LOCATE 1, 25: PRINT "Levers Left: "; levers
  222.                     oldsecond = TIMER
  223.                 END IF
  224.             NEXT cc
  225.         END IF
  226.     NEXT wxx
  227. NEXT wyy
  228.  
  229. 'The Random Red Bombs
  230. circles:
  231. _LIMIT 3000
  232. IF lv = 1 THEN
  233.     second = TIMER
  234.     IF second - oldsecond > 20 THEN lv = 0: slv = 0: GOTO nexone:
  235.     IF slv = 1 THEN RETURN
  236.     CIRCLE (lx, ly), 15, _RGB32(0, 0, 0)
  237.     CIRCLE (lx2, ly2), 15, _RGB32(0, 0, 0)
  238.     CIRCLE (lx3, ly3), 15, _RGB32(0, 0, 0)
  239.     CIRCLE (lx4, ly4), 15, _RGB32(0, 0, 0)
  240.     slv = 1
  241.     RETURN
  242. nexone:
  243. _LIMIT 3000
  244. IF rr = 1 THEN GOTO skip:
  245. rl = INT(RND * 1000) + 1
  246. IF rl > 975 AND rr = 0 THEN
  247.     lx = INT(RND * 750) + 1
  248.     ly = INT(RND * 500) + 1
  249.     lx2 = INT(RND * 750) + 1
  250.     ly2 = INT(RND * 500) + 1
  251.     lx3 = INT(RND * 750) + 1
  252.     ly3 = INT(RND * 500) + 1
  253.     lx4 = INT(RND * 750) + 1
  254.     ly4 = INT(RND * 500) + 1
  255.     rr = 1
  256. IF rr = 0 THEN RETURN
  257. skip:
  258. _LIMIT 3000
  259. IF bombs = 1 THEN GOTO skip2:
  260. CIRCLE (lx, ly), 15, _RGB32(255, 0, 0)
  261. CIRCLE (lx2, ly2), 15, _RGB32(255, 0, 0)
  262. CIRCLE (lx3, ly3), 15, _RGB32(255, 0, 0)
  263. CIRCLE (lx4, ly4), 15, _RGB32(255, 0, 0)
  264. bombs = 1
  265. skip2:
  266. _LIMIT 3000
  267. IF xx > lx - h / 3 AND xx < lx + h / 3 AND yy > ly - h / 3 AND yy < ly + h / 3 THEN GOSUB KABOOM:
  268. IF xx > lx2 - h / 3 AND xx < lx2 + h / 3 AND yy > ly2 - h / 3 AND yy < ly2 + h / 3 THEN GOSUB KABOOM:
  269. IF xx > lx3 - h / 3 AND xx < lx3 + h / 3 AND yy > ly3 - h / 3 AND yy < ly3 + h / 3 THEN GOSUB KABOOM:
  270. IF xx > lx4 - h / 3 AND xx < lx4 + h / 3 AND yy > ly4 - h / 3 AND yy < ly4 + h / 3 THEN GOSUB KABOOM:
  271. rl2 = INT(RND * 10000) + 1
  272. IF rl2 > 9985 THEN
  273.     rr = 0
  274.     bombs = 0
  275.     CIRCLE (lx, ly), 15, _RGB32(0, 0, 0)
  276.     CIRCLE (lx2, ly2), 15, _RGB32(0, 0, 0)
  277.     CIRCLE (lx3, ly3), 15, _RGB32(0, 0, 0)
  278.     CIRCLE (lx4, ly4), 15, _RGB32(0, 0, 0)
  279.  
  280. KABOOM:
  281. players = players - 1
  282. LINE (xx, yy)-(xx + INT(h / 3), yy + INT(h / 3)), _RGB32(0, 0, 0), BF
  283. CIRCLE (lx, ly), 15, _RGB32(0, 0, 0)
  284. CIRCLE (lx2, ly2), 15, _RGB32(0, 0, 0)
  285. CIRCLE (lx3, ly3), 15, _RGB32(0, 0, 0)
  286. CIRCLE (lx4, ly4), 15, _RGB32(0, 0, 0)
  287. FOR sz = 1 TO 10
  288.     CIRCLE (xx + (h / 3), yy + (h / 3)), sz, _RGB32(255, 0, 0)
  289.     SOUND 100, .25
  290.     _DELAY .1
  291. NEXT sz
  292. FOR sz = 1 TO 10 STEP .25
  293.     CIRCLE (xx + (h / 3), yy + (h / 3)), sz, _RGB32(0, 0, 0)
  294.     _DELAY .01
  295. NEXT sz
  296. xx = 400
  297. yy = 594
  298. rr = 0
  299. slv = 0
  300. bombs = 0
  301. players$ = STR$(players)
  302. _TITLE "Score: " + sc$ + "    Players: " + players$ + "   Level: " + level$ + "       Arrow Keys To Move, Esc or Q To Quit."
  303. IF players = 0 THEN
  304.     LOCATE 15, 45: PRINT "G A M E   O V E R"
  305.     LOCATE 17, 45: INPUT "Again(Y/N)"; ag$
  306.     IF LEFT$(ag$, 1) = "y" OR LEFT$(ag$, 1) = "Y" THEN CLEAR: GOTO begin:
  307.     END
  308.  
  309. 'Check to see if you got a candy.
  310. candy2:
  311. _LIMIT 3000
  312. FOR wy = -5 TO INT(h / 2) + 5
  313.     FOR wx = -5 TO INT(h / 2) + 5
  314.         IF POINT(xx + wx, yy + wy) = _RGB32(255, 161, 0) THEN
  315.             GOTO deletecandy:
  316.         END IF
  317.     NEXT wx
  318. NEXT wy
  319.  
  320. 'Check the area around you to delete the candy.
  321. deletecandy:
  322. _LIMIT 3000
  323. FOR wyy = -5 TO INT(h / 3) + 5
  324.     FOR wxx = -5 TO INT(h / 3) + 5
  325.         IF POINT(xx + wxx, yy + wyy) = _RGB32(255, 161, 0) THEN
  326.             FOR cc = 1 TO c
  327.                 IF xx + wxx = candyx(cc) AND yy + wyy = candyy(cc) THEN
  328.                     CIRCLE (candyx(cc), candyy(cc)), 4, _RGB32(0, 0, 0)
  329.                     PAINT (candyx(cc), candyy(cc)), _RGB32(0, 0, 0)
  330.                     SOUND 100, .5
  331.                     co = co + 1
  332.                     co2 = 100 - co
  333.                     IF co2 < 0 THEN co2 = 0
  334.                     LOCATE 1, 1: PRINT "Candy To Get: "; co2
  335.                     mouth = 1
  336.                     oldmsec = TIMER
  337.                     sc = sc + 10
  338.                     sc$ = STR$(sc)
  339.                     players$ = STR$(players)
  340.                     _TITLE "Score: " + sc$ + "    Players: " + players$ + "   Level: " + level$ + "       Arrow Keys To Move, Esc or Q To Quit."
  341.                 END IF
  342.             NEXT cc
  343.         END IF
  344.     NEXT wxx
  345. NEXT wyy
  346. IF co2 = 0 AND levers = 0 THEN
  347.     level = level + 1
  348.     co = 0
  349.     level$ = STR$(level)
  350.     _TITLE "Score: " + sc$ + "   Level: " + level$ + "       Arrow Keys To Move, Esc or Q To Quit."
  351.     GOTO level:
  352.  
  353. you:
  354. _LIMIT 3000
  355. oldxx = xx
  356. oldyy = yy
  357. xx = xx + drx
  358. yy = yy + dry
  359.  
  360. IF xx < 5 THEN xx = 5
  361. IF xx > 795 THEN xx = 795
  362. IF yy < 15 THEN yy = 15
  363. IF yy > 595 THEN yy = 595
  364.  
  365. 'Check to see if you hit the walls.
  366. FOR wx = -1 TO INT(h / 3)
  367.     FOR wy = -1 TO INT(h / 3)
  368.         IF POINT(xx + wx, yy + wy) = _RGB32(col1, col2, col3) THEN
  369.             yy = oldyy: xx = oldxx
  370.             RETURN
  371.         END IF
  372.     NEXT wy
  373. NEXT wx
  374.  
  375. 'Erase and draw you.
  376. LINE (oldxx, oldyy)-(oldxx + INT(h / 3), oldyy + INT(h / 3)), _RGB32(0, 0, 0), BF
  377. LINE (xx, yy)-(xx + INT(h / 3), yy + INT(h / 3)), _RGB32(0, 255, 0), BF
  378. LINE (xx, yy)-(xx + INT(h / 3), yy + 3), _RGB32(139, 116, 105), BF
  379.  
  380. ex1 = (xx + (INT(h / 3) / 2) / 2)
  381. ex2 = (xx + (INT(h / 3) / 2) / .65)
  382. ey = (yy + (INT(h / 3) / 2) / 2)
  383. mx = (xx + (INT(h / 3) / 2))
  384. my = (yy + (INT(h / 2.2) / 2))
  385. ny = (yy + (h / 2.85) / 2)
  386.  
  387. CIRCLE (ex1, ey), 2, _RGB32(0, 127, 255)
  388. PAINT (ex1, ey), _RGB32(0, 127, 255)
  389. CIRCLE (ex2, ey), 2, _RGB32(0, 127, 255)
  390. PAINT (ex2, ey), _RGB32(0, 127, 255)
  391.  
  392. IF mouth = 1 THEN GOTO skip3:
  393. CIRCLE (mx, my), 2.5, _RGB32(0, 0, 0)
  394. PAINT (mx, my), _RGB32(0, 0, 0)
  395. skip3:
  396. IF mouth = 1 THEN
  397.     CIRCLE (mx, my), 2.5, _RGB32(254, 254, 254)
  398.     PAINT (mx, my), _RGB32(254, 254, 254)
  399.     msec = TIMER
  400.     IF msec - oldmsec > .25 THEN mouth = 0
  401.  
  402. CIRCLE (mx, ny), 1.5, _RGB32(127, 128, 127)
  403. PAINT (mx, ny), _RGB32(127, 128, 127)
  404.  
  405. IF h > 74 THEN dl = .003
  406. IF h <= 74 AND h >= 55 THEN dl = .004
  407. IF h < 55 THEN dl = .005
  408.  
  409.  
« Last Edit: August 30, 2019, 01:36:47 am by SierraKen »