QB64.org Forum

Active Forums => Programs => Topic started by: SierraKen on August 28, 2019, 08:26:57 pm

Title: Search-Man Game
Post by: SierraKen 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.  
Title: Re: Search-Man Game
Post by: SierraKen 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.  
Title: Re: Search-Man Game
Post by: bplus 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.

Title: Re: Search-Man Game
Post by: SierraKen 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.
Title: Re: Search-Man Game
Post by: bplus 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
Title: Re: Search-Man Game
Post by: bplus 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?
Title: Re: Search-Man Game
Post by: SierraKen 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?
Title: Re: Search-Man Game
Post by: SierraKen 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.  
Title: Re: Search-Man Game
Post by: bplus 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.
Title: Re: Search-Man Game
Post by: SierraKen 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.  

Title: Re: Search-Man Game
Post by: bplus 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. :)
Title: Re: Search-Man Game
Post by: SierraKen 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.  
Title: Re: Search-Man Game
Post by: SierraKen 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.
Title: Re: Search-Man Game
Post by: bplus 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.



Title: Re: Search-Man Game
Post by: SierraKen 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.  
Title: Re: Search-Man Game
Post by: SierraKen on August 31, 2019, 08:55:48 pm
I'm trying to make a new version of this game called Search-Man 2 which, if I can do it, would be more fun than the first one. Instead of bombs appearing at random, it has 3 enemies that move through the walls, candies, etc. to go straight to your location in a slow way. The part of knowing what direction to go to I already have finished I believe. But the part I don't know hardly anything about is using the PUT statement to make the enemies leave the graphics behind them that they fly over. And also not leave a trail. I am VERY close though (I hope). I am using an example from the WIKI pages that I found a few days ago and today I put it in the game. One of the enemies fly perfectly without leaving any trace at all or leave any trail behind. But it's the other 2 enemies that I am having a hard time with. They leave a trail of red behind them. Plus there's 2 other enemies that move which I have no idea where they came from! LOL Can someone help me out on this? Someone that has used PUT and GET before to make sprites go over other graphics. I am soooo close I think. The example also uses the WAIT command with numbers that I have no idea where they got them from.  Here is my Search-Man 2 so far. Notice how I use arrays and then GET statements for all 3 of them before the main loop to setup the enemy graphics. The WIKI example only uses 1 sprite that you move, mine has 3 sprites that the computer moves. I tried it without the WAIT statements and got the same thing, but I put them back to show.

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

Also, here is the code to the Wiki example in case you are wondering about it:

Code: QB64: [Select]
  1. DEFINT A-Z
  2. DIM BG(300), Box(300), SC(127) ' BG holds background images. Box holds the Box image.
  3.  
  4. SCREEN 13 ' graphic coordinate minimums are 0 to 319 column or 199 row maximums.
  5. ' set up screen background
  6. COLOR 4: LOCATE 10, 5: PRINT "Multikey Keyboard input routine"
  7. COLOR 10: LOCATE 12, 4: PRINT "Use the arrow keys to move the box."
  8. LOCATE 13, 4: PRINT "Note that you can press two or more"
  9. LOCATE 14, 4: PRINT "keys at once for diagonal movement!"
  10. COLOR 14: LOCATE 16, 4: PRINT " Also demonstrates how GET and PUT "
  11. LOCATE 17, 4: PRINT "are used to preserve the background."
  12. COLOR 11: LOCATE 20, 11: PRINT "Press [Esc] to quit"
  13.  
  14. x = 150: y = 50: PX = x: PY = y ' actual box starting position
  15.  
  16. GET (x, y)-(x + 15, y + 15), BG() ' GET original BG at start box position
  17. LINE (x, y)-(x + 15, y + 15), 9, BF ' the plain blue box to move
  18. GET (x, y)-(x + 15, y + 15), Box() ' GET to Box Array
  19.  
  20. DO 'main loop
  21.     t! = TIMER + .05
  22.     DO ' 1 Tick (1/18th second) keypress scancode read loop
  23.         a$ = INKEY$ ' So the keyboard buffer won't get full
  24.         code% = INP(&H60) ' Get keyboard scan code from port 96
  25.         IF code% < 128 THEN SC(code%) = 1 ELSE SC(code% - 128) = 0 'true/false values to array
  26.     LOOP UNTIL TIMER > t! ' loop until one tick has passed
  27.  
  28.     PX = x: PY = y ' previous coordinates
  29.     IF SC(75) = 1 THEN x = x - 5: IF x < 0 THEN x = 0
  30.     IF SC(77) = 1 THEN x = x + 5: IF x > 304 THEN x = 304
  31.     IF SC(72) = 1 THEN y = y - 5: IF y < 0 THEN y = 0
  32.     IF SC(80) = 1 THEN y = y + 5: IF y > 184 THEN y = 184
  33.     IF x <> PX OR y <> PY THEN ' look for a changed coordinate value
  34.         WAIT 936, 8: PUT (PX, PY), BG(), PSET ' replace previous BG first
  35.         GET (x, y)-(x + 15, y + 15), BG() ' GET BG at new position before box is set
  36.         PUT (x, y), Box(), PSET ' PUT box image at new position
  37.     END IF
  38.  
  39. LOOP UNTIL SC(1) = 1 ' main loop until [Esc] key (scan code 1) is pressed
  40.  
  41.  
Title: Re: Search-Man Game
Post by: bplus on September 01, 2019, 10:01:22 am
Ken,

It seems to me allot easier to erase screen at every loop and redraw background and all in new positions than to draw over only moving items. You would't have to worry about leaving traces of old images.

_PUTIMAGE works very fast putting up images stored in handles, I think it is a GET and PUT wrapped in one by getting an image from one place and storing it or taking a stored image and drawing it back on main screen or isolated assembly "screen".

Ah! now I have idea for fireflys with trails and backgrounds both :)

Title: Re: Search-Man Game
Post by: SierraKen on September 01, 2019, 07:01:40 pm
B+, I tried for hours to try to do that today and yesterday, just won't work because the maze is drawn before the main loop, as  well as the candy and levers. I can easily do that with just you and the enemies, but not with the rest. I would have to redraw the rest as well which I don't know how to do. It would seem you can just copy everything with like COPYIMAGE but it's not that easy to figure out where to put the commands, etc. Maybe I just need a rest for now. lol
Title: Re: Search-Man Game
Post by: bplus on September 01, 2019, 07:09:00 pm
B+, I tried for hours to try to do that today and yesterday, just won't work because the maze is drawn before the main loop, as  well as the candy and levers. I can easily do that with just you and the enemies, but not with the rest. I would have to redraw the rest as well which I don't know how to do. It would seem you can just copy everything with like COPYIMAGE but it's not that easy to figure out where to put the commands, etc. Maybe I just need a rest for now. lol

Yeah, you'd have to rethink everything from ground up. Completely not your style. But I think you can get POINT info off an image just remember to say _SOURCE imagehandle& is your image before you try.

Your maze can be saved as image, there! it's saved in a container, now you can redraw it when ever needed!

'Draw maze
maze& = _newimage(_width, _height, 32)
_putimage , 0, maze&  'from screen to maze& handle

do
    _putimage , maze&, 0   'from maze to screen effectively clears your screen
   'redraw or _putimage all other action figures

   'process


  _display  ' stop flicker
  _limit x   'put limit on how fast it is allowed to loop around   
loop

Draw one candy and one lever, put their image in a handle, use an array to track their x, y locations

Use _putimage to set the image onto screen where ever you want as many times as you want, saves you from redraw AND erase!
Title: Re: Search-Man Game
Post by: SierraKen on September 01, 2019, 08:07:56 pm
Your code doesn't erase the screen, this:
 _putimage , maze&, 0   'from maze to screen effectively clears your screen.

I haven't changed anything for the candy or levers. I copy the maze (and everything in it), right before the main loop.
Then in the main loop is where I added this:  _PUTIMAGE , maze&, 0   
I tried adding the line (0,0)-(800,600),_rgb32(0,0,0),bf  but that just erases it all and doesn't bring it back.

This is what I have:

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. DIM bg1(300), enemy1(300)
  53. DIM bg2(300), enemy2(300)
  54. DIM bg3(300), enemy3(300)
  55. x = 400: y = 300
  56. t = 0
  57. c = 0
  58. drx = 0: dry = 0
  59. lv = 0: slv = 0: bombs = 0
  60. lev = 0
  61. levers = 5
  62. mouth = 0
  63. h = INT(RND * 60) + 40
  64. lx = INT(RND * 700) + 20
  65. ly = INT(RND * 300) + 20
  66. lx2 = INT(RND * 700) + 20
  67. ly2 = INT(RND * 300) + 20
  68. lx3 = INT(RND * 700) + 20
  69. ly3 = INT(RND * 300) + 20
  70.  
  71. 'Randomly choose a wall color.
  72. col = INT(RND * 8) + 1
  73. 'green
  74. IF col = 1 THEN
  75.     col1 = 33: col2 = 230: col3 = 7
  76. 'purple
  77. IF col = 2 THEN
  78.     col1 = 152: col2 = 7: col3 = 230
  79. 'yellow
  80. IF col = 3 THEN
  81.     col1 = 247: col2 = 255: col3 = 8
  82. 'orange
  83. IF col = 4 THEN
  84.     col1 = 255: col2 = 156: col3 = 8
  85. 'red
  86. IF col = 5 THEN
  87.     col1 = 255: col2 = 8: col3 = 8
  88. 'blue
  89. IF col = 6 THEN
  90.     col1 = 8: col2 = 131: col3 = 255
  91. 'white
  92. IF col = 7 THEN
  93.     col1 = 255: col2 = 255: col3 = 255
  94. 'greenish-blue
  95. IF col = 8 THEN
  96.     col1 = 10: col2 = 240: col3 = 201
  97.  
  98. 'Make the walls.
  99.  
  100.     _LIMIT 3000
  101.     again:
  102.     t = t + 1
  103.     IF t = 30000000 THEN EXIT DO
  104.     oldx = x
  105.     oldy = y
  106.     oldd = d
  107.     d = INT(RND * 4) + 1
  108.     IF d = oldd THEN GOTO again:
  109.     IF d = 1 THEN x = x + h
  110.     IF d = 2 THEN x = x - h
  111.     IF d = 3 THEN y = y + h
  112.     IF d = 4 THEN y = y - h
  113.     IF x > 800 - h OR x < h OR y > 600 - h OR y < h THEN x = 400: y = 300: GOTO again:
  114.     IF POINT(x, y) = _RGB32(col1, col2, col3) THEN GOTO again:
  115.     LINE (oldx, oldy)-(x, y), _RGB32(col1, col2, col3)
  116. t = 0
  117. FOR tt = 1 TO INT(1000 / h)
  118.     x2 = INT(RND * 800) + 1
  119.     y2 = INT(RND * 600) + 1
  120.     d2 = INT(RND * 2) + 1
  121.     IF d2 = 1 THEN LINE (x2, y2)-(x2 + h, y2 + h), _RGB32(0, 0, 0), BF
  122.     IF d2 = 2 THEN LINE (x2, y2)-(x2 + h, y2 + h), _RGB32(0, 0, 0), BF
  123. NEXT tt
  124.  
  125. 'Setup the levers
  126.     levers:
  127.     leverx = INT(RND * 600) + 100
  128.     levery = INT(RND * 400) + 100
  129.     'Check for walls.
  130.     FOR cx = -2 TO 7
  131.         FOR cy = -2 TO 17
  132.             IF POINT(leverx + cx, levery + cy) = _RGB32(col1, col2, col3) THEN GOTO levers:
  133.         NEXT cy
  134.     NEXT cx
  135.     'Check for other levers.
  136.     FOR cx = -2 TO 7
  137.         FOR cy = -2 TO 17
  138.             IF POINT(leverx + cx, levery + cy) = _RGB32(22, 255, 122) THEN GOTO levers:
  139.         NEXT cy
  140.     NEXT cx
  141.     LINE (leverx, levery)-(leverx + 5, levery + 15), _RGB32(22, 255, 122), BF
  142.     lev = lev + 1
  143.     leverx(lev) = leverx: levery(lev) = levery
  144.     IF lev = 5 THEN EXIT DO
  145.  
  146. 'Setup the candy.
  147.     candy:
  148.     candyx = INT(RND * 600) + 100
  149.     candyy = INT(RND * 400) + 100
  150.     'Check for walls.
  151.     FOR cx = -7 TO 7
  152.         FOR cy = -7 TO 7
  153.             IF POINT(candyx + cx, candyy + cy) = _RGB32(col1, col2, col3) THEN GOTO candy:
  154.         NEXT cy
  155.     NEXT cx
  156.     'Check for other candy.
  157.     FOR cx = -7 TO 7
  158.         FOR cy = -7 TO 7
  159.             IF POINT(candyx + cx, candyy + cy) = _RGB32(255, 161, 0) THEN GOTO candy:
  160.         NEXT cy
  161.     NEXT cx
  162.     'Check for levers.
  163.     FOR cx = -2 TO 7
  164.         FOR cy = -2 TO 17
  165.             IF POINT(candyx + cx, candyy + cy) = _RGB32(22, 255, 122) THEN GOTO candy:
  166.         NEXT cy
  167.     NEXT cx
  168.     CIRCLE (candyx, candyy), 4, _RGB32(255, 161, 0)
  169.     PAINT (candyx, candyy), _RGB32(255, 161, 0)
  170.     c = c + 1
  171.     candyx(c) = candyx: candyy(c) = candyy
  172.     IF c = 150 THEN EXIT DO
  173.  
  174. 'You are coords xx and yy.
  175. xx = 400
  176. yy = 594
  177. _TITLE "Arrow Keys To Move, Esc or Q To Quit."
  178.  
  179.  
  180. maze& = _NEWIMAGE(_WIDTH, _HEIGHT, 32)
  181. _PUTIMAGE , 0, maze& 'from screen to maze& handle
  182.  
  183.  
  184. 'The Main Loop
  185.     _LIMIT 3000
  186.     _PUTIMAGE , maze&, 0
  187.     a$ = INKEY$
  188.     IF a$ = CHR$(0) + CHR$(72) THEN
  189.         dry = -1
  190.         drx = 0
  191.     END IF
  192.     IF a$ = CHR$(0) + CHR$(80) THEN
  193.         dry = 1
  194.         drx = 0
  195.     END IF
  196.     IF a$ = CHR$(0) + CHR$(77) THEN
  197.         drx = 1
  198.         dry = 0
  199.     END IF
  200.     IF a$ = CHR$(0) + CHR$(75) THEN
  201.         drx = -1
  202.         dry = 0
  203.     END IF
  204.     IF a$ = CHR$(27) THEN END
  205.     IF a$ = "q" OR a$ = "Q" THEN END
  206.     GOSUB you:
  207.     GOSUB candy2:
  208.     GOSUB lev:
  209.     GOSUB enemies:
  210.     _DISPLAY
  211.  
  212. lev:
  213. _LIMIT 3000
  214. FOR wy = -15 TO INT(h / 3) + 15
  215.     FOR wx = -15 TO INT(h / 3) + 15
  216.         IF POINT(xx + wx, yy + wy) = _RGB32(22, 255, 122) THEN
  217.             GOTO deletelever:
  218.         END IF
  219.     NEXT wx
  220. NEXT wy
  221.  
  222. 'Check the area around you to delete the lever.
  223. deletelever:
  224. _LIMIT 3000
  225. FOR wyy = -5 TO INT(h / 3) + 15
  226.     FOR wxx = -5 TO INT(h / 3) + 5
  227.         IF POINT(xx + wxx, yy + wyy) = _RGB32(22, 255, 122) THEN
  228.             FOR cc = 1 TO lev
  229.                 IF xx + wxx = leverx(cc) AND yy + wyy = levery(cc) THEN
  230.                     LINE (leverx(cc), levery(cc))-(leverx(cc) + 5, levery(cc) + 15), _RGB32(0, 0, 0), BF
  231.                     FOR snd = 450 TO 550 STEP 25
  232.                         SOUND snd, .15
  233.                     NEXT snd
  234.                     rr = 0
  235.                     lv = 1
  236.                     levers = levers - 1
  237.                     IF levers < 0 THEN levers = 0
  238.                     LOCATE 1, 25: PRINT "Levers Left: "; levers
  239.                     oldsecond = TIMER
  240.                 END IF
  241.             NEXT cc
  242.         END IF
  243.     NEXT wxx
  244. NEXT wyy
  245. IF co2 = 0 AND levers = 0 THEN
  246.     level = level + 1
  247.     co = 0
  248.     level$ = STR$(level)
  249.     _TITLE "Score: " + sc$ + "   Level: " + level$ + "       Arrow Keys To Move, Esc or Q To Quit."
  250.     GOTO level:
  251.  
  252. 'The enemies
  253. enemies:
  254. _LIMIT 3000
  255.  
  256.  
  257. IF xx > lx THEN lx = lx + .2
  258. IF xx < lx THEN lx = lx - .2
  259. IF yy > ly THEN ly = ly + .2
  260. IF yy < ly THEN ly = ly - .2
  261. IF lx > 775 THEN lx = 775
  262. IF lx < 15 THEN lx = 15
  263. IF ly > 575 THEN ly = 575
  264. IF ly < 15 THEN ly = 15
  265.  
  266. IF xx > lx2 THEN lx2 = lx2 + .2
  267. IF xx < lx2 THEN lx2 = lx2 - .2
  268. IF yy > ly2 THEN ly2 = ly2 + .2
  269. IF yy < ly2 THEN ly2 = ly2 - .2
  270. IF lx2 > 775 THEN lx2 = 775
  271. IF lx2 < 15 THEN lx2 = 15
  272. IF ly2 > 575 THEN ly2 = 575
  273. IF ly2 < 15 THEN ly2 = 15
  274.  
  275. IF xx > lx3 THEN lx3 = lx3 + .2
  276. IF xx < lx3 THEN lx3 = lx3 - .2
  277. IF yy > ly3 THEN ly3 = ly3 + .2
  278. IF yy < ly3 THEN ly3 = ly3 - .2
  279. IF lx3 > 775 THEN lx3 = 775
  280. IF lx3 < 15 THEN lx3 = 15
  281. IF ly3 > 575 THEN ly3 = 575
  282. IF ly3 < 15 THEN ly3 = 15
  283.  
  284. LINE (lx, ly)-(lx + 15, ly + 15), _RGB32(255, 0, 0), BF
  285. LINE (lx2, ly2)-(lx2 + 15, ly2 + 15), _RGB32(255, 0, 0), BF
  286. LINE (lx3, ly3)-(lx3 + 15, ly3 + 15), _RGB32(255, 0, 0), BF
  287.  
  288. _PUTIMAGE , 0, maze& 'from screen to maze& handle
  289.  
  290. FOR wy = -10 TO INT(h / 3) + 10
  291.     FOR wx = -10 TO INT(h / 3) + 10
  292.         IF POINT(xx + wx, yy + wy) = _RGB32(255, 0, 0) THEN GOSUB KABOOM:
  293.     NEXT wx
  294. NEXT wy
  295.  
  296. KABOOM:
  297. players = players - 1
  298. LINE (xx, yy)-(xx + INT(h / 3), yy + INT(h / 3)), _RGB32(0, 0, 0), BF
  299. FOR sz = 14 TO 15
  300.     CIRCLE (lx, ly), sz, _RGB32(0, 0, 0)
  301.     CIRCLE (lx2, ly2), sz, _RGB32(0, 0, 0)
  302.     CIRCLE (lx3, ly3), sz, _RGB32(0, 0, 0)
  303.     CIRCLE (lx4, ly4), sz, _RGB32(0, 0, 0)
  304. NEXT sz
  305. FOR sz = 1 TO 10
  306.     CIRCLE (xx + (h / 3), yy + (h / 3)), sz, _RGB32(255, 0, 0)
  307.     SOUND 100, .25
  308.     _DELAY .1
  309. NEXT sz
  310. FOR sz = 1 TO 10 STEP .25
  311.     CIRCLE (xx + (h / 3), yy + (h / 3)), sz, _RGB32(0, 0, 0)
  312.     _DELAY .01
  313. NEXT sz
  314. xx = 400
  315. yy = 594
  316. rr = 0
  317. slv = 0
  318. bombs = 0
  319. players$ = STR$(players)
  320. _TITLE "Score: " + sc$ + "    Players: " + players$ + "   Level: " + level$ + "       Arrow Keys To Move, Esc or Q To Quit."
  321. IF players = 0 THEN
  322.     LOCATE 15, 45: PRINT "G A M E   O V E R"
  323.     LOCATE 17, 45: INPUT "Again(Y/N)"; ag$
  324.     IF LEFT$(ag$, 1) = "y" OR LEFT$(ag$, 1) = "Y" THEN CLEAR: GOTO begin:
  325.     END
  326.  
  327. 'Check to see if you got a candy.
  328. candy2:
  329. _LIMIT 3000
  330. FOR wy = -5 TO INT(h / 2) + 5
  331.     FOR wx = -5 TO INT(h / 2) + 5
  332.         IF POINT(xx + wx, yy + wy) = _RGB32(255, 161, 0) THEN
  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.                     sc = sc + 10
  356.                     sc$ = STR$(sc)
  357.                     players$ = STR$(players)
  358.                     _TITLE "Score: " + sc$ + "    Players: " + players$ + "   Level: " + level$ + "       Arrow Keys To Move, Esc or Q To Quit."
  359.                 END IF
  360.             NEXT cc
  361.         END IF
  362.     NEXT wxx
  363. NEXT wyy
  364. IF co2 = 0 AND levers = 0 THEN
  365.     level = level + 1
  366.     co = 0
  367.     level$ = STR$(level)
  368.     _TITLE "Score: " + sc$ + "   Level: " + level$ + "       Arrow Keys To Move, Esc or Q To Quit."
  369.     GOTO level:
  370.  
  371. you:
  372. _LIMIT 3000
  373. oldxx = xx
  374. oldyy = yy
  375. xx = xx + drx
  376. yy = yy + dry
  377.  
  378. IF xx < 5 THEN xx = 5
  379. IF xx > 795 THEN xx = 795
  380. IF yy < 15 THEN yy = 15
  381. IF yy > 595 THEN yy = 595
  382.  
  383. 'Check to see if you hit the walls.
  384. FOR wx = -1 TO INT(h / 3)
  385.     FOR wy = -1 TO INT(h / 3)
  386.         IF POINT(xx + wx, yy + wy) = _RGB32(col1, col2, col3) THEN
  387.             yy = oldyy: xx = oldxx
  388.             RETURN
  389.         END IF
  390.     NEXT wy
  391. NEXT wx
  392.  
  393. 'Erase and draw you.
  394. LINE (oldxx, oldyy)-(oldxx + INT(h / 3), oldyy + INT(h / 3)), _RGB32(0, 0, 0), BF
  395. LINE (xx, yy)-(xx + INT(h / 3), yy + INT(h / 3)), _RGB32(0, 255, 0), BF
  396. LINE (xx, yy)-(xx + INT(h / 3), yy + 3), _RGB32(139, 116, 105), BF
  397.  
  398. ex1 = (xx + (INT(h / 3) / 2) / 2)
  399. ex2 = (xx + (INT(h / 3) / 2) / .65)
  400. ey = (yy + (INT(h / 3) / 2) / 2)
  401. mx = (xx + (INT(h / 3) / 2))
  402. my = (yy + (INT(h / 2.2) / 2))
  403. ny = (yy + (h / 2.85) / 2)
  404.  
  405. CIRCLE (ex1, ey), 2, _RGB32(0, 127, 255)
  406. PAINT (ex1, ey), _RGB32(0, 127, 255)
  407. CIRCLE (ex2, ey), 2, _RGB32(0, 127, 255)
  408. PAINT (ex2, ey), _RGB32(0, 127, 255)
  409.  
  410. IF mouth = 1 THEN GOTO skip3:
  411. CIRCLE (mx, my), 2.5, _RGB32(0, 0, 0)
  412. PAINT (mx, my), _RGB32(0, 0, 0)
  413. skip3:
  414. IF mouth = 1 THEN
  415.     CIRCLE (mx, my), 2.5, _RGB32(254, 254, 254)
  416.     PAINT (mx, my), _RGB32(254, 254, 254)
  417.     msec = TIMER
  418.     IF msec - oldmsec > .25 THEN mouth = 0
  419.  
  420. CIRCLE (mx, ny), 1.5, _RGB32(127, 128, 127)
  421. PAINT (mx, ny), _RGB32(127, 128, 127)
  422.  
  423. IF h >= 55 THEN dl = .003
  424. IF h < 55 THEN dl = .004
  425.  
  426.  
Title: Re: Search-Man Game
Post by: bplus on September 01, 2019, 08:31:28 pm
Oh man you had an extra _putimage in there around 330, take it out, looks good then at least for the few seconds I watched.

Man you let the red guys go right through the walls!

For candy and levers, you have to track what's not eaten and redraw or _putimage what remains after the cls of _putimage of the maze& same loop, do all processing in ypur GOSUBS but do all the drawing and _putimages in main loop.

arrays candyX, candyY, candyEaten, leverX, leverY, leverGone, MonsterX, MonsterY

do
_putimage , maze&, 0
for i = 1 to Ncandy
if candyEaten = 0 then drawcandy candyX(i), candyY(i) or _PutImage (CandyX(i), candyY(i)), candy&, 0
next
for i = 1 to Nlevers
if leverGone = 0 then drawlever leverX(i), leverY(i) or _PutImage (leverX(i), leverY(i)), lever&, 0
next
for i = 1 to nRedSquares
drawRedSquares MonsterX(i), monsterY(i) or _putimage ( MonsterX(i), MonsterY(i) ), Monster&, 0
next
drawYou youX, youY

'process all updates to characters
Display
limit
loop

There! all your drawing is done in main loop

Setup candy, lever and monster allot like you did with Maze& on different sizes and specify (x, y) locations for _putimage to know where to put them on screen.
Title: Re: Search-Man Game
Post by: SierraKen on September 01, 2019, 10:26:22 pm
Thanks B+. I removed the unnecessary _PUTIMAGE and they move perfectly now! But I am worn out completely. I saved everything you wrote on your last post on a Notepad and will try to get to it sometime soon. But I can't promise anything. Working so hard with so little success on this lately has been a real downer. But I might try what you said sometime this week. Thanks again, at least I learned some things today with _PUTIMAGE. That can be used in an infinite amount of games and programs!
Title: Re: Search-Man Game
Post by: bplus on September 02, 2019, 08:58:27 am
Yeah, _PUTIMAGE is extremely powerful for applications.

You look at it in Wiki and cringe at it's complexity but 4 main elements in order

before 1st comma optional, if no spec then whole screen gets image
1. your specify the box for the destination, the specification is just like drawing a box with LINE
    (x, y)  < top left corner
    -         a dash
    (x + width, y + height)   or STEP(width, height)  (you can Step for top left (x, y) too)

before 2nd comma
2. the Source handle (LONG type best) = where your image is currently located, screen = 0

before 3rd comma
3. the Destination handle (LONG type best) = where you want image to go, on screen or into image container

last after 3rd comma
4. the part of source (like a box on a screen again) you want to store or move to destination

It looks complicated but you can take any part (rectangle) of a source and fit it into any part (rectangle) in the destination area it is automatically sized.

_PUTIMAGE is like a moving van of images, pickup and install as you specify. Pickup is Source, Deliver is Destination, 1 and 4 specify the exact room locations at Pickup or Delivery.
Title: Re: Search-Man Game
Post by: SierraKen on September 02, 2019, 12:33:09 pm
Thanks, with my very bad short term memory problems, that just went through one eye and out the other. So I put it on a Notepad. I learn from experience so I have to use this many times to get the hang of it.
Title: Re: Search-Man Game
Post by: bplus on September 02, 2019, 01:13:14 pm
Absolutely, without practice nothing sticks. You can do it, you have the will!