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

0 Members and 1 Guest are viewing this topic.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Search-Man Game
« Reply #15 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.  
« Last Edit: August 31, 2019, 09:07:00 pm by SierraKen »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Search-Man Game
« Reply #16 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 :)


Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Search-Man Game
« Reply #17 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

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Search-Man Game
« Reply #18 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!
« Last Edit: September 01, 2019, 07:19:14 pm by bplus »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Search-Man Game
« Reply #19 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.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Search-Man Game
« Reply #20 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.
« Last Edit: September 01, 2019, 08:51:20 pm by bplus »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Search-Man Game
« Reply #21 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!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Search-Man Game
« Reply #22 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.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Search-Man Game
« Reply #23 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.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Search-Man Game
« Reply #24 on: September 02, 2019, 01:13:14 pm »
Absolutely, without practice nothing sticks. You can do it, you have the will!