Author Topic: courtesy cubes :)  (Read 4936 times)

0 Members and 1 Guest are viewing this topic.

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
courtesy cubes :)
« on: February 15, 2022, 05:01:51 pm »
this should make a game :)

Code: QB64: [Select]
  1. mon = _NEWIMAGE(800, 800, 32): SCREEN mon: _DEST mon
  2.  
  3. DIM SHARED temp_color(9) AS _INTEGER64
  4.  
  5. map_x = 30
  6. map_y = 30
  7.  
  8. mb_c = 54: DIM mb(mb_c - 1, 9)
  9.  
  10. DIM map(map_x - 1, map_y - 1)
  11.  
  12. speed = .05
  13. size_block = 23
  14. size_wall = .9
  15.  
  16. cent_x = (_WIDTH(mon) - size_block * map_x) / 2
  17. cent_y = (_HEIGHT(mon) - size_block * map_y) / 2
  18.  
  19.  
  20. DIM d(3, 1) AS _BYTE
  21. d(0, 0) = 0: d(0, 1) = -1
  22. d(1, 0) = 1: d(1, 1) = 0
  23. d(2, 0) = 0: d(2, 1) = 1
  24. d(3, 0) = -1: d(3, 1) = 0
  25.  
  26.  
  27. 'make walls
  28. FOR tx = 0 TO map_x - 1: FOR ty = 0 TO map_y - 1: map(tx, ty) = ABS(tx = 0 OR ty = 0 OR tx = map_x - 1 OR ty = map_y - 1): NEXT ty, tx
  29.  
  30. 'make mover bricks
  31. FOR t = 0 TO mb_c - 1
  32.     DO: mb(t, 1) = INT(1 + (map_x - 2) * RND(1)): mb(t, 2) = INT(1 + (map_y - 2) * RND(1)): mb(t, 3) = INT(4 * RND(1)): busy = 0
  33.         FOR t2 = 0 TO mb_c - 1: IF mb(t2, 0) = 0 THEN _CONTINUE
  34.             busy = busy OR (mb(t2, 1) = mb(t, 1) AND mb(t2, 2) = mb(t, 2))
  35.             sik = (mb(t, 3) MOD 2) = (mb(t2, 3) MOD 2) 'ha egy sikban mozognak
  36.             busy = busy OR ((mb(t2, 1) = mb(t, 1)) AND sik)
  37.             busy = busy OR ((mb(t2, 2) = mb(t, 2)) AND sik)
  38.         NEXT t2
  39.     LOOP WHILE busy
  40.     mb(t, 0) = 1 'lets busy
  41.  
  42. 'mb array
  43. '0 ena/disa
  44. '1,2 XY location
  45. '3 'direction
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54. '------------------------------------------- BOSS CYCLE
  55.     'draw non mover blocks
  56.     FOR tx = 0 TO map_x - 1: xc = tx * size_block + .5 + cent_x
  57.         FOR ty = 0 TO map_y - 1: yc = ty * size_block + .5 + cent_y
  58.             SELECT CASE map(tx, ty)
  59.                 CASE 1
  60.                     size = size_block * size_wall / 2
  61.                     LINE (xc - size, yc - size)-(xc + size, yc + size), _RGB32(255, 50, 50), BF
  62.             END SELECT
  63.     NEXT ty, tx
  64.  
  65.     'draw mover blocks
  66.     FOR amb = 0 TO mb_c - 1: IF mb(amb, 0) = 0 THEN _CONTINUE
  67.         xc = mb(amb, 1) * size_block + .5 + cent_x
  68.         yc = mb(amb, 2) * size_block + .5 + cent_y
  69.         size = size_block * size_wall / 2
  70.         LINE (xc - size, yc - size)-(xc + size, yc + size), _RGB32(50, 255, 50), BF
  71.     NEXT amb
  72.  
  73.     'moving mover bricks
  74.  
  75.     FOR amb = 0 TO mb_c - 1: IF mb(amb, 0) = 0 THEN _CONTINUE
  76.         tx = CINT(mb(amb, 1) + d(mb(amb, 3), 0) * (speed + .5))
  77.         ty = CINT(mb(amb, 2) + d(mb(amb, 3), 1) * (speed + .5))
  78.  
  79.  
  80.         IF map(tx, ty) = 1 THEN mb(amb, 3) = (mb(amb, 3) + 2) MOD 4: _CONTINUE
  81.         dontgo = 0
  82.         FOR t = 0 TO mb_c - 1: IF mb(t, 0) = 0 THEN _CONTINUE
  83.             IF (mb(t, 3) MOD 2) = (mb(amb, 3) MOD 2) THEN _CONTINUE
  84.             tx2 = CINT(mb(t, 1))
  85.             ty2 = CINT(mb(t, 2))
  86.             IF tx = tx2 AND ty = ty2 THEN dontgo = 1: EXIT FOR
  87.         NEXT t
  88.  
  89.  
  90.  
  91.         mb(amb, 1) = mb(amb, 1) + d(mb(amb, 3), 0) * speed * (dontgo XOR 1)
  92.         mb(amb, 2) = mb(amb, 2) + d(mb(amb, 3), 1) * speed * (dontgo XOR 1)
  93.  
  94.  
  95.     NEXT amb
  96.  
  97.  
  98.     _DISPLAY: CLS
  99.  
  100.  
  101.  

Offline _vince

  • Seasoned Forum Regular
  • Posts: 422
    • View Profile
Re: courtesy cubes :)
« Reply #1 on: February 15, 2022, 05:30:20 pm »
wow nice! here is a nice screensaver us newbs here can appreciate.  Now are the momenta and velocities gaussian distributed?

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: courtesy cubes :)
« Reply #2 on: February 15, 2022, 05:38:25 pm »
I don't understand Gauss :) There is a sorting principle: don't have one
 movement in a row or column of 2 stones. so max stone = x * y
I was just thinking of a minimalist 3D skill game that could be written from a few lines.

Offline _vince

  • Seasoned Forum Regular
  • Posts: 422
    • View Profile
Re: courtesy cubes :)
« Reply #3 on: February 15, 2022, 05:43:09 pm »
I was just thinking of a minimalist 3D skill game that could be written from a few lines.

A dense pasture of cows -- now get your tractor from one corner to the next without hitting any

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: courtesy cubes :)
« Reply #4 on: February 16, 2022, 02:40:13 pm »
this is a great idea! :)

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: courtesy cubes :)
« Reply #5 on: February 16, 2022, 04:56:14 pm »
a simple change to make more bricks. So far, there could have been 1 brick in 1 plane, so there could have been a maximum of X x Y bricks on the track. it had to be inserted so that there could be more bricks in 1 plane, but they would not cross each other.
The solution: when a brick moving in parallel meets, it loses direction, it releases a moving brick when it meets perpendicularly.

Code: QB64: [Select]
  1. mon = _NEWIMAGE(800, 800, 32): SCREEN mon: _DEST mon
  2.  
  3. DIM SHARED temp_color(9) AS _INTEGER64
  4.  
  5. map_x = 30
  6. map_y = 30
  7. mb_c = 150
  8. speed = .08
  9. size_block = 23
  10. size_wall = .9 'size percent size_block
  11. b_colors = 10
  12.  
  13.  
  14.  
  15.  
  16.  
  17. cent_x = (_WIDTH(mon) - size_block * map_x) / 2
  18. cent_y = (_HEIGHT(mon) - size_block * map_y) / 2
  19.  
  20.  
  21. DIM d(3, 1) AS _BYTE, map(map_x - 1, map_y - 1), mb(mb_c - 1, 9): d(3, 1) = -1: d(0, 0) = 1: d(1, 1) = 1: d(2, 0) = -1: d(3, 1) = -1 'directions
  22.  
  23.  
  24. 'make colors
  25. DIM b_colors(b_colors - 1) AS _INTEGER64
  26. FOR t = 0 TO b_colors - 1
  27.     b_colors(t) = _RGB32(100 + 100 * RND(1), 100 + 100 * RND(1), 100 + 100 * RND(1))
  28.  
  29. 'make walls
  30. FOR tx = 0 TO map_x - 1: FOR ty = 0 TO map_y - 1: map(tx, ty) = ABS(tx = 0 OR ty = 0 OR tx = map_x - 1 OR ty = map_y - 1): NEXT ty, tx
  31.  
  32. 'make mover bricks
  33. FOR t = 0 TO mb_c - 1
  34.     DO: mb(t, 1) = INT(1 + (map_x - 2) * RND(1)): mb(t, 2) = INT(1 + (map_y - 2) * RND(1)): mb(t, 3) = INT(4 * RND(1)): busy = 0
  35.         FOR t2 = 0 TO mb_c - 1: IF mb(t2, 0) = 0 THEN _CONTINUE
  36.             busy = busy OR (mb(t2, 1) = mb(t, 1) AND mb(t2, 2) = mb(t, 2))
  37.         NEXT t2
  38.     LOOP WHILE busy
  39.     mb(t, 0) = 1 'lets busy
  40.     mb(t, 5) = INT(b_colors * RND(1))
  41.  
  42. 'mb array
  43. '0 ena/disa
  44. '1,2 XY location
  45. '3 'direction
  46. '4 stop counter
  47. '5 color index
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55. '------------------------------------------- BOSS CYCLE
  56. DO: _LIMIT 30: IF INKEY$ = " " THEN RUN
  57.     'draw non mover blocks
  58.     FOR tx = 0 TO map_x - 1: xc = tx * size_block + .5 + cent_x
  59.         FOR ty = 0 TO map_y - 1: yc = ty * size_block + .5 + cent_y
  60.             PSET (xc, yc), _RGB32(100, 100, 100)
  61.             SELECT CASE map(tx, ty)
  62.                 CASE 1
  63.                     size = size_block * size_wall / 2
  64.                     LINE (xc - size, yc - size)-(xc + size, yc + size), _RGB32(255, 50, 50), BF
  65.             END SELECT
  66.     NEXT ty, tx
  67.  
  68.     'draw mover blocks
  69.     FOR amb = 0 TO mb_c - 1
  70.         xc = mb(amb, 1) * size_block + .5 + cent_x: yc = mb(amb, 2) * size_block + .5 + cent_y: size = size_block * size_wall / 2
  71.         IF mb(amb, 0) = 0 THEN _CONTINUE
  72.         LINE (xc - size, yc - size)-(xc + size, yc + size), b_colors(mb(amb, 5)), BF
  73.     NEXT amb
  74.  
  75.     'moving mover bricks
  76.  
  77.     FOR amb = 0 TO mb_c - 1: IF mb(amb, 0) = 0 THEN _CONTINUE
  78.         p(0) = CINT(mb(amb, 1) + d(mb(amb, 3), 0) * (speed + .5))
  79.         p(1) = CINT(mb(amb, 2) + d(mb(amb, 3), 1) * (speed + .5))
  80.  
  81.  
  82.         dontgo = 0: letsneg = 0
  83.  
  84.         FOR t = 0 TO mb_c - 1: IF mb(t, 0) = 0 OR t = amb THEN _CONTINUE
  85.             vr = mb(t, 3) MOD 2
  86.             IF vr = (mb(amb, 3) MOD 2) THEN
  87.                 IF (mb(t, 1 + (vr XOR 1))) <> (mb(amb, 1 + (vr XOR 1))) THEN _CONTINUE
  88.                 letsneg = letsneg OR (ABS(mb(t, 1 + vr) - mb(amb, 1 + vr)) < 1)
  89.             ELSE
  90.                 dontgo = dontgo OR (ABS(p(0) - mb(t, 1)) < 1 AND ABS(p(1) - mb(t, 2)) < 1)
  91.             END IF
  92.         NEXT t
  93.  
  94.         '        mb(amb, 3) = (mb(amb, 3) + ABS((letsneg AND mb(amb, 4) = 0) OR map(p(0), p(1)) = 1) * 2) MOD 4
  95.         mb(amb, 3) = (mb(amb, 3) + ABS((letsneg) OR map(p(0), p(1)) = 1) * 2) MOD 4
  96.  
  97.         IF dontgo THEN
  98.             mb(amb, 4) = (mb(amb, 4)) + 1: IF mb(amb, 4) > 5 / speed THEN mb(amb, 3) = (mb(amb, 3) + 2) MOD 4
  99.         ELSE
  100.             mb(amb, 1) = mb(amb, 1) + d(mb(amb, 3), 0) * speed: mb(amb, 2) = mb(amb, 2) + d(mb(amb, 3), 1) * speed: mb(amb, 4) = 0
  101.         END IF
  102.     NEXT amb
  103.  
  104.     _DISPLAY: CLS
  105.  
  106.  
  107.  
  108.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: courtesy cubes :)
« Reply #6 on: February 17, 2022, 11:42:05 am »
That actually starts to look intelligent like an ant farm.

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: courtesy cubes :)
« Reply #7 on: February 17, 2022, 06:03:43 pm »
I did control the game tonight.

I'll start in 3D tomorrow, I'll be curious. The game is easy in 2d because we can see what will happen from above, but in 3d, it has to be fast.

Code: QB64: [Select]
  1. DIM SHARED size_block, size_wall, me(9), monx, mony, mb_c, map_x, map_y
  2. '----------------- settings
  3. monx = 800: mony = INT(monx / _DESKTOPWIDTH * _DESKTOPHEIGHT)
  4. map_x = 30
  5. map_y = 30
  6. mb_c = 120 'maximum mover bricks
  7.  
  8. speed_min = .03
  9. speed_max = .09
  10.  
  11. me(5) = .5 'the size of my extent relative to a brick
  12. me_speed = .1 'my speed
  13.  
  14. size_block = 20
  15. size_wall = .95 'size percent size_block
  16. b_colors = 5
  17. shdw_c = 5
  18. '----------------------------
  19. CONST pip180 = 3.141592 / 180
  20.  
  21. 'me install
  22. 'me array params '0,1,2=X,Y,Z 3=angXY 4=angXZ 5'XY dimension
  23. me(0) = -1: me(1) = -1 'my start locate
  24. size = 100
  25. temp = _NEWIMAGE(size, size, 32): _DEST temp: CLS 0, _RGB32(10, 10, 10)
  26. CIRCLE (size / 2, size / 2), size / 2 * size_wall, _RGB32(200, 200, 200)
  27. PAINT (size / 2, size / 2), _RGB32(200, 200, 200)
  28. _CLEARCOLOR _RGB32(10, 10, 10)
  29. me_text = _COPYIMAGE(temp, 33): _FREEIMAGE temp
  30.  
  31. 'SCREEN temp
  32. 'END
  33.  
  34.  
  35.  
  36.  
  37.  
  38. DIM SHARED temp_color(9) AS _INTEGER64
  39.  
  40. 'directions
  41. DIM d(3, 1) AS _BYTE: d(3, 1) = -1: d(0, 0) = 1: d(1, 1) = 1: d(2, 0) = -1: d(3, 1) = -1
  42. DIM SHARED map(map_x - 1, map_y - 1), mb(mb_c - 1, 9)
  43. 'make colors
  44. DIM b_colors(b_colors - 1) AS _INTEGER64: FOR t = 1 TO b_colors - 1: b_colors(t) = _RGB32(50 + 150 * RND(1), 50 + 150 * RND(1), 50 + 150 * RND(1)): NEXT t
  45. b_colors(0) = _RGB32(150, 20, 20) 'wall color
  46.  
  47. 'make textures
  48. marg = .12: tmax = 50: tmin = 20
  49. DIM text_mb(mb_c - 1, shdw_c - 1), text_wall(shdw_c - 1)
  50. FOR t = 0 TO shdw_c - 1: size = INT(tmax - (tmax - tmin) / (shdw_c - 1) * t): dark = 1 - 1 / (shdw_c - 1) * t
  51.  
  52.     stand_temp = _NEWIMAGE(size, size, 32): _DEST stand_temp: CLS , _RGB32(50, 50, 50) 'frame color
  53.     LINE (size * marg, size * marg)-(size - size * marg, size - size * marg), _RGB32(180, 180, 180), BF
  54.  
  55.     'make wall
  56.     FOR t2 = 0 TO b_colors - 1: temp = _COPYIMAGE(stand_temp, 32)
  57.         trans = _NEWIMAGE(5, 5, 32): _DEST trans: CLS , _RGBA32(_RED32(b_colors(t2)) * dark, _GREEN32(b_colors(t2)) * dark, _BLUE32(b_colors(t2)) * dark, 150)
  58.         _SOURCE trans: _DEST temp: _BLEND temp: _PUTIMAGE: _FREEIMAGE trans
  59.         trans = _NEWIMAGE(5, 5, 32): _DEST trans: CLS , _RGBA32(0, 0, 0, (1 - dark) * 255)
  60.         _SOURCE trans: _DEST temp: _PUTIMAGE: _FREEIMAGE trans
  61.     text_mb(t2, t) = _COPYIMAGE(temp, 33): _FREEIMAGE temp: NEXT t2: _FREEIMAGE stand_temp
  62.  
  63.  
  64.  
  65. 'make walls
  66. FOR tx = 0 TO map_x - 1: FOR ty = 0 TO map_y - 1: map(tx, ty) = ABS(tx = 0 OR ty = 0 OR tx = map_x - 1 OR ty = map_y - 1): NEXT ty, tx
  67.  
  68. 'add walls within the framework
  69. add_wall_c = 3: add_wall_p(0) = .8: add_wall_p(1) = .8: FOR t = 1 TO add_wall_c
  70.     DO: FOR t2 = 0 TO 3: p(t2) = map_x * add_wall_p(t2 MOD 2) * RND(1) + map_x * (1 - add_wall_p(t2 MOD 2)) / 2: NEXT t2
  71.     dis = SQR((p(0) - p(2)) ^ 2 + (p(1) - p(3)) ^ 2): LOOP WHILE dis < 5: dis = dis * .7
  72. FOR t2 = 0 TO dis: map(INT(p(0) + (p(2) - p(0)) / dis * t2), INT(p(1) + (p(3) - p(1)) / dis * t2)) = 2: NEXT t2, t
  73.  
  74.  
  75. 'money install
  76. temp = _NEWIMAGE(8, 16, 32): _DEST temp: PRINT "$";: text_money = _COPYIMAGE(temp, 33): _FREEIMAGE temp
  77. DO: money_x = INT(1 + (map_x - 2) * RND(1)): money_y = INT(1 + (map_y - 2) * RND(1)): LOOP WHILE map(money_y, money_x)
  78. map(money_x, money_y) = 3
  79.  
  80.  
  81. 'make mover bricks
  82. FOR t = 0 TO mb_c - 1: agent_timer = TIMER
  83.     DO: mb(t, 1) = INT(1 + (map_x - 2) * RND(1)): mb(t, 2) = INT(1 + (map_y - 2) * RND(1)): mb(t, 3) = INT(4 * RND(1)): busy = 0
  84.         FOR tx = -1 TO 1: FOR ty = -1 TO 1: busy = busy OR SGN(map(tx + mb(t, 1), ty + mb(t, 2))): NEXT ty, tx
  85.         FOR t2 = 0 TO mb_c - 1: IF mb(t2, 0) = 0 OR busy THEN _CONTINUE
  86.         busy = busy OR (SQR((mb(t2, 1) - mb(t, 1)) ^ 2 + (mb(t2, 2) - mb(t, 2)) ^ 2) < 2): NEXT t2: IF ABS(agent_timer - TIMER) > 2 THEN EXIT FOR
  87.     LOOP WHILE busy: mb(t, 0) = 1: mb(t, 5) = 1 + INT((b_colors - 1) * RND(1))
  88.     mb(t, 6) = speed_min + (speed_max - speed_min) * RND(1)
  89.  
  90.  
  91.  
  92. 'entri brick to the area
  93. t = INT(2 * RND(1)): posx = INT((1 + (map_x - 2) * RND(1)) * t) + INT(2 * RND(1)) * (map_x - 1) * ABS(t = 0)
  94. posy = INT((1 + (map_y - 2) * RND(1)) * (t XOR 1)) + INT(2 * RND(1)) * (map_x - 1) * ABS((t XOR 1) = 0): map(posx, posy) = 0
  95.  
  96.  
  97.  
  98.  
  99. 'mb array
  100. '0 ena/disa
  101. '1,2 XY location
  102. '3 'direction
  103. '4 stop counter
  104. '5 color index
  105. '6 speed
  106.  
  107.  
  108.  
  109.  
  110.  
  111. mon = _NEWIMAGE(monx, mony, 32): SCREEN mon: _DEST mon
  112. 'CLS , _RGB32(20, 20, 20)
  113. _DISPLAYORDER _HARDWARE , _SOFTWARE: _FULLSCREEN '_SQUAREPIXELS ', _SMOOTH
  114.  
  115.  
  116.  
  117. LOCATE mony / 16 - 3, 1
  118. PRINT "control-type1: WASD+mouse (map rotating)"
  119. PRINT "control-type2: arrows (no map rotating)"
  120. PRINT "map zoom: mouse wheel"
  121.  
  122. '------------------------------------------- BOSS CYCLE
  123.     'draw non mover blocks
  124.     FOR tx = 0 TO map_x - 1: FOR ty = 0 TO map_y - 1: IF map(tx, ty) THEN draw_brick tx, ty, text_mb(0, 0), 1
  125.     NEXT ty, tx
  126.  
  127.     'draw mover blocks
  128.     FOR amb = 0 TO mb_c - 1: IF mb(amb, 0) THEN draw_brick mb(amb, 1), mb(amb, 2), text_mb(mb(amb, 5), 0), 1
  129.     NEXT amb
  130.  
  131.     'draw me
  132.     IF dead = 0 OR (dead AND INT(2 * RND(1))) THEN draw_brick me(0), me(1), me_text, me(5)
  133.  
  134.     'draw money
  135.     IF storyline = 0 THEN draw_brick money_x, money_y, text_money, 1
  136.  
  137.  
  138.     'moving mover bricks
  139.     FOR amb = 0 TO mb_c - 1: IF mb(amb, 0) = 0 THEN _CONTINUE
  140.         p(0) = CINT(mb(amb, 1) + d(mb(amb, 3), 0) * (mb(amb, 6) + .5))
  141.         p(1) = CINT(mb(amb, 2) + d(mb(amb, 3), 1) * (mb(amb, 6) + .5)): dontgo = 0: letsneg = 0
  142.  
  143.         FOR t = 0 TO mb_c - 1: IF mb(t, 0) = 0 OR t = amb OR dontgo THEN _CONTINUE
  144.             vr = mb(t, 3) MOD 2: vr2 = vr = (mb(amb, 3) MOD 2)
  145.             letsneg = letsneg OR (((ABS(mb(t, 1 + vr) - mb(amb, 1 + vr)) < 1) AND (mb(t, 1 + (vr XOR 1))) = (mb(amb, 1 + (vr XOR 1)))) AND vr2)
  146.             dontgo = dontgo OR ((ABS(p(0) - mb(t, 1)) < 1 AND ABS(p(1) - mb(t, 2)) < 1) AND (vr2 = 0))
  147.         NEXT t
  148.  
  149.         mb(amb, 3) = (mb(amb, 3) + ABS(((letsneg) OR map(p(0), p(1)) = 2 OR map(p(0), p(1)) = 3) OR (p(0) = 0 OR p(0) = map_x - 1 OR p(1) = 0 OR p(1) = map_y - 1)) * 2) MOD 4
  150.         mb(amb, 4) = (mb(amb, 4) + ABS(dontgo)) * ABS(dontgo)
  151.         mb(amb, 3) = (mb(amb, 3) + 2 * ABS((mb(amb, 4) > 5 / mb(amb, 6)) AND dontgo)) MOD 4
  152.         mb(amb, 1) = mb(amb, 1) + d(mb(amb, 3), 0) * mb(amb, 6) * ABS(dontgo = 0)
  153.         mb(amb, 2) = mb(amb, 2) + d(mb(amb, 3), 1) * mb(amb, 6) * ABS(dontgo = 0)
  154.  
  155.  
  156.     NEXT amb
  157.  
  158.     'control me
  159.     mousex = 0: mousey = 0: mw = 0: WHILE _MOUSEINPUT: mousex = mousex + _MOUSEMOVEMENTX: mousey = mousey + _MOUSEMOVEMENTY: mw = mw + _MOUSEWHEEL: WEND
  160.     k_left = _KEYDOWN(19200) OR _KEYDOWN(ASC("a")): k_right = _KEYDOWN(19712) OR _KEYDOWN(ASC("d"))
  161.     k_up = _KEYDOWN(18432) OR _KEYDOWN(ASC("w")) OR _MOUSEBUTTON(1): k_down = _KEYDOWN(20480) OR _KEYDOWN(ASC("s"))
  162.  
  163.     me(3) = (me(3) + mousex * 1) * ABS((_KEYDOWN(19200) OR _KEYDOWN(19712) OR _KEYDOWN(18432) OR _KEYDOWN(20480)) = 0)
  164.  
  165.     size_block = size_block - mw: IF size_block < 3 THEN size_block = 3 ELSE IF size_block > 140 THEN size_block = 140
  166.  
  167.     IF dead = 0 THEN
  168.         IF crash_test(me(0), me(1)) THEN
  169.             try_speed = speed_max * 1.1
  170.             try = -1: FOR atry = 0 TO 3
  171.                 IF crash_test(me(0) + d(atry, 0) * try_speed, me(1) + d(atry, 1) * try_speed) = 0 THEN try = atry: EXIT FOR
  172.             NEXT atry: IF try = -1 THEN dead = 1
  173.             IF dead = 0 THEN me(0) = me(0) + d(atry, 0) * try_speed: me(1) = me(1) + d(atry, 1) * try_speed
  174.         END IF
  175.  
  176.         go = me_speed * ABS(k_left OR k_right OR k_up OR k_down): go_ang = k_down * 180 + 90 * (k_left - k_right) + me(3)
  177.         go_x = SIN(go_ang * pip180) * go + me(0)
  178.         go_y = -COS(go_ang * pip180) * go + me(1)
  179.         IF crash_test(go_x, go_y) = 0 THEN
  180.             me(0) = go_x: me(1) = go_y
  181.         END IF
  182.  
  183.  
  184.     END IF
  185.  
  186.     'cheats
  187.     inkey2$ = INKEY$
  188.     IF inkey2$ = " " THEN RUN
  189.     IF inkey2$ = "o" THEN dead = 1 'reborn
  190.     IF inkey2$ = "p" THEN dead = 0 'dead
  191.  
  192.     _DISPLAY
  193.  
  194.     'money near- storyline
  195.     IF storyline = 0 AND SQR((me(0) - money_x) ^ 2 + (me(1) - money_y) ^ 2) < 1.2 THEN storyline = 1: map(money_x, money_y) = 0
  196.     IF storyline = 1 AND (me(0) > 0 AND me(0) < map_x - 1 AND me(1) > 0 AND me(1) < map_y - 1) = 0 THEN storyline = 2
  197.  
  198.     SELECT CASE storyline
  199.         CASE 0: s$ = "GET THE MONEY !"
  200.         CASE 1: s$ = "ESCAPE OUTSIDE THE WALL !"
  201.         CASE 2: s$ = "Mission compeleted !"
  202.     END SELECT
  203.  
  204.     IF dead THEN s$ = "you dead ,mission incompleted !"
  205.     COLOR _RGB32(255 * RND(1), 255 * RND(1), 255 * RND(1)): LOCATE 1, 1: _PRINTSTRING (30, 30), s$ + SPACE$(20)
  206.  
  207. SUB rotate_2d (x, y, ang): x1 = -(x * COS(ang) - y * SIN(ang)): y1 = -(x * SIN(ang) + y * COS(ang)): x = x1: y = y1: END SUB
  208.  
  209. SUB draw_brick (x, y, text, relsize)
  210.     DIM x(3), y(3): xc = (x - me(0)) * size_block + .5: yc = (y - me(1)) * size_block + .5: rot = (-me(3) + 180) * pip180
  211.     rotate_2d xc, yc, rot: xc = xc + monx / 2: yc = yc + mony / 2: size = size_block * size_wall * .5 * relsize
  212.     FOR t = 0 TO 3: x(t) = size * -(SGN(t AND 1) * 2 - 1): y(t) = size * (ABS(t < 2) * 2 - 1)
  213.     rotate_2d x(t), y(t), rot: x(t) = INT(x(t) + xc): y(t) = INT(y(t) + yc): NEXT t
  214.     wtext = _WIDTH(text) - 1: htext = _HEIGHT(text) - 1
  215.     _MAPTRIANGLE (0, 0)-(wtext, 0)-(0, htext), text TO(x(0), y(0))-(x(1), y(1))-(x(2), y(2)), , _SMOOTH
  216.     _MAPTRIANGLE (wtext, htext)-(wtext, 0)-(0, htext), text TO(x(3), y(3))-(x(1), y(1))-(x(2), y(2)), , _SMOOTH
  217.  
  218. FUNCTION crash_test (x, y)
  219.     FOR myp = 0 TO 3
  220.         mx = x + me(5) * .5 * (SGN(myp AND 1) * 2 - 1): my = y + me(5) * .5 * (SGN(myp AND 2) * 2 - 1)
  221.  
  222.         FOR amb = 0 TO mb_c - 1: IF mb(amb, 0) = 0 THEN _CONTINUE
  223.             IF mx > mb(amb, 1) - .5 AND mx < mb(amb, 1) + .5 AND my > mb(amb, 2) - .5 AND my < mb(amb, 2) + .5 THEN crash_test = 1: EXIT FUNCTION
  224.         NEXT amb
  225.  
  226.         FOR tx = 0 TO map_x - 1: FOR ty = 0 TO map_y - 1: IF map(tx, ty) = 0 THEN _CONTINUE
  227.                 IF mx > tx - .5 AND mx < tx + .5 AND my > ty - .5 AND my < ty + .5 THEN crash_test = 1: EXIT FUNCTION
  228.     NEXT ty, tx, myp
  229.  
  230.  
« Last Edit: February 17, 2022, 06:09:45 pm by MasterGy »

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: courtesy cubes :)
« Reply #8 on: February 17, 2022, 06:15:43 pm »
bring the money out of the wall and be careful not to squeeze the stones!

get_the_money.jpg
* get_the_money.jpg (Filesize: 93.68 KB, Dimensions: 795x635, Views: 137)

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: courtesy cubes :)
« Reply #9 on: February 19, 2022, 01:29:00 pm »
done in 3d. You can set the strength at the beginning of the source code. speeds, number of golds, number of moving cubes.

Control: WASD + mouse
Mission: Collect all the gold and go out!
Survive not to squeeze the cubes!

The program does not have a file.

 
xscreenshot_moverbricks.jpg


Code: QB64: [Select]
  1. 'MasterGy 2022
  2.  
  3. DIM SHARED size_block, size_wall, me(9), monx, mony, mb_c, map_x, map_y, crash_test_disable, shdw_c
  4. '----------------- settings ---------------------------------------------------------------------------------------------
  5.  
  6.  
  7.  
  8.  
  9. map_x = 30 'size map X
  10. map_y = 30 'size map Y
  11. speed_min = .03 'bricks minimum speed
  12. speed_max = .09 'bricks maximum speed
  13. money_c = 5 'money number what you find
  14. mb_c = 60 'maximum mover bricks in the map
  15. me_speed = .1 'my speed
  16. mouse_sens = 1
  17.  
  18.  
  19.  
  20.  
  21.  
  22. '------------------------------------------------------ advanced settings -------------------------------------------------------------
  23. monx = 800: mony = INT(monx / _DESKTOPWIDTH * _DESKTOPHEIGHT)
  24. tile_marg = 4
  25. me(5) = .5 'the size of my extent relative to a brick
  26.  
  27. size_block = 20
  28. size_wall = .9 'size percent size_block
  29. b_colors = 8
  30. shdw_c = 50
  31. '----------------------------
  32. CONST pip180 = 3.141592 / 180
  33.  
  34. 'me install 'ME array params '0,1,2=X,Y,Z 3=angXY 4=angXZ 5'XY dimension
  35. me(0) = -1: me(1) = -1: me(2) = .4 'my start locate
  36. size = 100
  37. temp = _NEWIMAGE(size, size, 32): _DEST temp: CLS 0, _RGB32(10, 10, 10)
  38. CIRCLE (size / 2, size / 2), size / 2 * size_wall, _RGB32(200, 200, 200)
  39. PAINT (size / 2, size / 2), _RGB32(200, 200, 200): _CLEARCOLOR _RGB32(10, 10, 10): me_text = _COPYIMAGE(temp, 33): _FREEIMAGE temp
  40.  
  41. DIM SHARED temp_color(9) AS _INTEGER64
  42.  
  43.  
  44. 'shadows
  45. DIM SHARED shdw(16383) AS _BYTE: DIM SHARED darking_array(shdw_c - 1)
  46. FOR t = 0 TO 16383: ashdw = INT((shdw_c - 1) * 0.0006 * t): IF ashdw > shdw_c - 1 THEN ashdw = shdw_c - 1
  47. shdw(t) = ashdw: NEXT t
  48.  
  49.  
  50. 'directions
  51. DIM d(3, 1) AS _BYTE: d(3, 1) = -1: d(0, 0) = 1: d(1, 1) = 1: d(2, 0) = -1: d(3, 1) = -1
  52. DIM SHARED map(map_x - 1, map_y - 1), mb(mb_c - 1, 9)
  53. 'make colors
  54. DIM SHARED b_colors(b_colors - 1) AS _INTEGER64: FOR t = 1 TO b_colors - 1: b_colors(t) = _RGB32(50 + 150 * RND(1), 50 + 150 * RND(1), 50 + 150 * RND(1)): NEXT t
  55. b_colors(0) = _RGB32(150, 20, 20) 'wall color
  56.  
  57. 'make textures
  58. marg = .12: tmax = 30: tmin = 30
  59. DIM SHARED text_mb(mb_c - 1, shdw_c - 1), text_wall(shdw_c - 1)
  60. FOR t = 0 TO shdw_c - 1: size = INT(tmax - (tmax - tmin) / (shdw_c - 1) * t): dark = 1 - 1 / (shdw_c - 1) * t
  61.     stand_temp = _NEWIMAGE(size, size, 32): _DEST stand_temp: CLS , _RGB32(50, 50, 50) 'frame color
  62.     LINE (size * marg, size * marg)-(size - size * marg, size - size * marg), _RGB32(180, 180, 180), BF
  63.  
  64.     'make wall
  65.     FOR t2 = 0 TO b_colors - 1: temp = _COPYIMAGE(stand_temp, 32): _DEST temp
  66.         IF t2 = 0 THEN LINE (0, 0)-(size, size), _RGB32(50, 50, 50): LINE (size, 0)-(0, size), _RGB32(50, 50, 50) 'no mover wall
  67.         trans = _NEWIMAGE(5, 5, 32): _DEST trans: CLS , _RGBA32(_RED32(b_colors(t2)) * dark, _GREEN32(b_colors(t2)) * dark, _BLUE32(b_colors(t2)) * dark, 150)
  68.         _SOURCE trans: _DEST temp: _BLEND temp: _PUTIMAGE: _FREEIMAGE trans
  69.         trans = _NEWIMAGE(5, 5, 32): _DEST trans: CLS , _RGBA32(0, 0, 0, (1 - dark) * 255)
  70.         _SOURCE trans: _DEST temp: _PUTIMAGE: _FREEIMAGE trans
  71.     text_mb(t2, t) = _COPYIMAGE(temp, 33): _FREEIMAGE temp: NEXT t2: _FREEIMAGE stand_temp
  72.  
  73.  
  74. 'skys_color
  75. DIM text_sky(999)
  76.  
  77.  
  78. FOR t = 0 TO 499
  79.     temp = _NEWIMAGE(3, 3, 32): _DEST temp: CLS , _RGB32(20, 20, 255 / 499 * t): text_sky(t) = _COPYIMAGE(temp, 33): _FREEIMAGE temp
  80.  
  81. 'make walls
  82. FOR tx = 0 TO map_x - 1: FOR ty = 0 TO map_y - 1: map(tx, ty) = ABS(tx = 0 OR ty = 0 OR tx = map_x - 1 OR ty = map_y - 1): NEXT ty, tx
  83.  
  84. 'add walls within the framework
  85. add_wall_c = 3: add_wall_p(0) = .8: add_wall_p(1) = .8: FOR t = 1 TO add_wall_c
  86.     DO: FOR t2 = 0 TO 3: p(t2) = map_x * add_wall_p(t2 MOD 2) * RND(1) + map_x * (1 - add_wall_p(t2 MOD 2)) / 2: NEXT t2
  87.     dis = SQR((p(0) - p(2)) ^ 2 + (p(1) - p(3)) ^ 2): LOOP WHILE dis < 5: dis = dis * .7
  88. FOR t2 = 0 TO dis: map(INT(p(0) + (p(2) - p(0)) / dis * t2), INT(p(1) + (p(3) - p(1)) / dis * t2)) = 2: NEXT t2, t
  89.  
  90.  
  91. 'money install
  92. DIM SHARED text_money(9)
  93. FOR t = 0 TO 9: temp = _NEWIMAGE(8, 16, 32): _DEST temp: COLOR _RGB32(256 * RND(1), 256 * RND(1), 256 * RND(1)): PRINT "$";
  94. _CLEARCOLOR _RGB32(0, 0, 0): text_money(t) = _COPYIMAGE(temp, 33): _FREEIMAGE temp: NEXT t
  95. DIM money(money_c - 1, 9)
  96. FOR t = 0 TO money_c - 1: DO: money(t, 0) = INT(1 + (map_x - 2) * RND(1)): money(t, 1) = INT(1 + (map_y - 2) * RND(1))
  97. LOOP WHILE map(money(t, 0), money(t, 1)): map(money(t, 0), money(t, 1)) = 3: NEXT t
  98.  
  99. 'make mover bricks
  100. FOR t = 0 TO mb_c - 1: agent_timer = TIMER
  101.     DO: mb(t, 1) = INT(1 + (map_x - 2) * RND(1)): mb(t, 2) = INT(1 + (map_y - 2) * RND(1)): mb(t, 3) = INT(4 * RND(1)): busy = 0
  102.         FOR tx = -1 TO 1: FOR ty = -1 TO 1: busy = busy OR SGN(map(tx + mb(t, 1), ty + mb(t, 2))): NEXT ty, tx
  103.         FOR t2 = 0 TO mb_c - 1: IF mb(t2, 0) = 0 OR busy THEN _CONTINUE
  104.         busy = busy OR (SQR((mb(t2, 1) - mb(t, 1)) ^ 2 + (mb(t2, 2) - mb(t, 2)) ^ 2) < 2): NEXT t2: IF ABS(agent_timer - TIMER) > 2 THEN EXIT FOR
  105.     LOOP WHILE busy: mb(t, 0) = 1: mb(t, 5) = 1 + INT((b_colors - 1) * RND(1))
  106.     mb(t, 6) = speed_min + (speed_max - speed_min) * RND(1)
  107.  
  108.  
  109.  
  110. 'entri brick to the area
  111. t = INT(2 * RND(1)): posx = INT((1 + (map_x - 2) * RND(1)) * t) + INT(2 * RND(1)) * (map_x - 1) * ABS(t = 0)
  112. posy = INT((1 + (map_y - 2) * RND(1)) * (t XOR 1)) + INT(2 * RND(1)) * (map_x - 1) * ABS((t XOR 1) = 0): map(posx, posy) = 0
  113.  
  114.  
  115.  
  116.  
  117. 'mb array
  118. '0 ena/disa
  119. '1,2 XY location
  120. '3 'direction
  121. '4 stop counter
  122. '5 color index
  123. '6 speed
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134. '------------------------------------------- BOSS CYCLE
  135.     draw_2d_map = _KEYDOWN(100306) OR _KEYDOWN(100305) 'if press CTRL, show the 2d map
  136.  
  137.     'draw non mover blocks
  138.  
  139.  
  140.     FOR tx = -tile_marg TO map_x - 1 + tile_marg: FOR ty = -tile_marg TO map_y - 1 + tile_marg
  141.             IF tx < 0 OR tx > map_x - 1 OR ty < 0 OR ty > map_y - 1 THEN
  142.  
  143.             ELSE
  144.                 IF map(tx, ty) = 1 OR map(tx, ty) = 2 THEN
  145.                     IF draw_2d_map THEN draw_brick_2d tx, ty, 1, 0
  146.                     draw_brick_3d tx, ty, 0, 1
  147.                 ELSE
  148.  
  149.                 END IF
  150.             END IF
  151.             tile_3d tx, ty
  152.     NEXT ty, tx
  153.  
  154.     'draw mover blocks
  155.     FOR amb = 0 TO mb_c - 1:
  156.         IF mb(amb, 0) THEN
  157.             IF draw_2d_map THEN draw_brick_2d mb(amb, 1), mb(amb, 2), 1, mb(amb, 5)
  158.             draw_brick_3d mb(amb, 1), mb(amb, 2), mb(amb, 5), 1
  159.         END IF
  160.     NEXT amb
  161.  
  162.     'draw me
  163.     IF (dead = 0 OR (dead AND INT(2 * RND(1)))) AND draw_2d_map THEN draw_brick_2d me(0), me(1), me(5), mb(0, 0)
  164.  
  165.     'draw money
  166.     IF storyline = 0 THEN
  167.         FOR t = 0 TO money_c - 1: IF money(t, 2) THEN _CONTINUE
  168.             IF draw_2d_map THEN draw_brick_2d money(t, 0), money(t, 1), 1, -1
  169.             money_3d money(t, 0), money(t, 1)
  170.         NEXT t
  171.     END IF
  172.  
  173.     'moving mover bricks
  174.     FOR amb = 0 TO mb_c - 1: IF mb(amb, 0) = 0 THEN _CONTINUE
  175.         p(0) = CINT(mb(amb, 1) + d(mb(amb, 3), 0) * (mb(amb, 6) + .5))
  176.         p(1) = CINT(mb(amb, 2) + d(mb(amb, 3), 1) * (mb(amb, 6) + .5)): dontgo = 0: letsneg = 0
  177.  
  178.         FOR t = 0 TO mb_c - 1: IF mb(t, 0) = 0 OR t = amb OR dontgo THEN _CONTINUE
  179.             vr = mb(t, 3) MOD 2: vr2 = vr = (mb(amb, 3) MOD 2)
  180.             letsneg = letsneg OR (((ABS(mb(t, 1 + vr) - mb(amb, 1 + vr)) < 1) AND (mb(t, 1 + (vr XOR 1))) = (mb(amb, 1 + (vr XOR 1)))) AND vr2)
  181.             dontgo = dontgo OR ((ABS(p(0) - mb(t, 1)) < 1 AND ABS(p(1) - mb(t, 2)) < 1) AND (vr2 = 0))
  182.         NEXT t
  183.  
  184.         mb(amb, 3) = (mb(amb, 3) + ABS(((letsneg) OR map(p(0), p(1)) = 2 OR map(p(0), p(1)) = 3) OR (p(0) = 0 OR p(0) = map_x - 1 OR p(1) = 0 OR p(1) = map_y - 1)) * 2) MOD 4
  185.         mb(amb, 4) = (mb(amb, 4) + ABS(dontgo)) * ABS(dontgo)
  186.         mb(amb, 3) = (mb(amb, 3) + 2 * ABS((mb(amb, 4) > 5 / mb(amb, 6)) AND dontgo)) MOD 4
  187.         mb(amb, 1) = mb(amb, 1) + d(mb(amb, 3), 0) * mb(amb, 6) * ABS(dontgo = 0)
  188.         mb(amb, 2) = mb(amb, 2) + d(mb(amb, 3), 1) * mb(amb, 6) * ABS(dontgo = 0)
  189.  
  190.  
  191.     NEXT amb
  192.  
  193.     'control me
  194.     mousex = 0: mousey = 0: mw = 0: WHILE _MOUSEINPUT: mousex = mousex + _MOUSEMOVEMENTX: mousey = mousey + _MOUSEMOVEMENTY: mw = mw + _MOUSEWHEEL: WEND
  195.     k_left = _KEYDOWN(19200) OR _KEYDOWN(ASC("a")): k_right = _KEYDOWN(19712) OR _KEYDOWN(ASC("d"))
  196.     k_up = _KEYDOWN(18432) OR _KEYDOWN(ASC("w")) OR _MOUSEBUTTON(1): k_down = _KEYDOWN(20480) OR _KEYDOWN(ASC("s"))
  197.  
  198.     me(3) = me(3) + mousex * mouse_sens '* ABS((_KEYDOWN(19200) OR _KEYDOWN(19712) OR _KEYDOWN(18432) OR _KEYDOWN(20480)) = 0)
  199.     me(4) = me(4) + mousey * mouse_sens: IF ABS(me(4)) > 80 THEN me(4) = 80 * SGN(me(4))
  200.     size_block = size_block - mw: IF size_block < 3 THEN size_block = 3 ELSE IF size_block > 140 THEN size_block = 140
  201.  
  202.     IF dead = 0 THEN
  203.         IF crash_test(me(0), me(1)) THEN
  204.             try_speed = speed_max * 1.1
  205.             try = -1: FOR atry = 0 TO 3
  206.                 IF crash_test(me(0) + d(atry, 0) * try_speed, me(1) + d(atry, 1) * try_speed) = 0 THEN try = atry: EXIT FOR
  207.             NEXT atry: IF try = -1 THEN dead = 1
  208.             IF dead = 0 THEN me(0) = me(0) + d(atry, 0) * try_speed: me(1) = me(1) + d(atry, 1) * try_speed
  209.         END IF
  210.         try_ang_sc = 70
  211.         FOR try_ang = 0 TO try_ang_sc STEP 5: FOR try_ang_dir = 0 TO 1
  212.                 go = me_speed * ABS(k_left OR k_right OR k_up OR k_down) / try_ang_sc * (try_ang_sc - try_ang)
  213.                 go_ang = k_down * 180 + 90 * (k_left - k_right) + me(3) + (try_ang_dir * 2 - 1) * try_ang
  214.                 go_x = SIN(go_ang * pip180) * go + me(0): go_y = -COS(go_ang * pip180) * go + me(1)
  215.                 IF crash_test(go_x, go_y) = 0 THEN me(0) = go_x: me(1) = go_y: GOTO ok
  216.         NEXT try_ang_dir, try_ang
  217.         ok:
  218.  
  219.     END IF
  220.  
  221.     'cheats
  222.     inkey2$ = INKEY$
  223.     IF inkey2$ = " " THEN RUN
  224.     IF inkey2$ = "l" THEN crash_test_disable = crash_test_disable XOR 1
  225.     IF inkey2$ = "o" THEN dead = 1 'reborn
  226.     IF inkey2$ = "p" THEN dead = 0 'dead
  227.  
  228.     'sky draw
  229.     sky_flash = sky_flash - 0.02: IF sky_flash < 0 THEN sky_flash = 0
  230.     IF sky_flash > 1 THEN sky_flash = 1
  231.     IF dead THEN sky_ind = 490 * SGN(INT(TIMER * 50) AND 1) ELSE sky_ind = INT(490 * sky_flash)
  232.     asky = text_sky(sky_ind)
  233.     _MAPTRIANGLE (0, 0)-(0, 5)-(5, 0), asky TO(-16000, -16000, -10000)-(16000, -16000, -10000)-(-16000, 16000, -10000)
  234.     _MAPTRIANGLE (0, 0)-(0, 5)-(5, 0), asky TO(16000, 16000, -10000)-(16000, -16000, -10000)-(-16000, 16000, -10000)
  235.     _DISPLAY: CLS
  236.  
  237.     'money near- storyline
  238.     IF storyline = 0 THEN
  239.         FOR t = 0 TO money_c - 1
  240.             find_money = SQR((me(0) - money(t, 0)) ^ 2 + (me(1) - money(t, 1)) ^ 2) < 1.1 AND (money(t, 2) = 0)
  241.             IF find_money THEN money_sum = money_sum + 1: map(money(t, 0), money(t, 1)) = 0: money(t, 2) = 1: sky_flash = 1
  242.         NEXT t
  243.         storyline = storyline + ABS(money_sum = money_c)
  244.     END IF
  245.     IF storyline = 1 AND (me(0) > 0 AND me(0) < map_x - 1 AND me(1) > 0 AND me(1) < map_y - 1) = 0 THEN storyline = 2
  246.  
  247.     SELECT CASE storyline
  248.         CASE 0: s$ = "GET THE MONEY !   " + STR$(money_c) + " /" + STR$(money_sum)
  249.         CASE 1: s$ = "ESCAPE OUTSIDE THE WALL !"
  250.         CASE 2: s$ = "Mission compeleted ! "
  251.     END SELECT
  252.  
  253.     IF dead THEN s$ = "you dead ,mission incompleted !"
  254.  
  255.     COLOR _RGB32(255 * RND(1), 255 * RND(1), 255 * RND(1)): LOCATE 3, (monx / 8 - LEN(s$)) / 2: PRINT s$
  256.     IF draw_2d_map = 0 THEN COLOR _RGB32(255, 255, 255), _RGBA(0, 0, 0, 0): LOCATE mony / 16 - 1, 1: PRINT "CTRL - show 2Dmap        mouse wheel:2Dmap zoom";
  257.  
  258.  
  259. SUB rotate_2d (x, y, ang): x1 = -(x * COS(ang) - y * SIN(ang)): y1 = -(x * SIN(ang) + y * COS(ang)): x = x1: y = y1: END SUB
  260.  
  261. FUNCTION crash_test (x, y): IF crash_test_disable THEN EXIT FUNCTION
  262.     FOR myp = 0 TO 3: mx = x + me(5) * .5 * (SGN(myp AND 1) * 2 - 1): my = y + me(5) * .5 * (SGN(myp AND 2) * 2 - 1)
  263.         FOR amb = 0 TO mb_c - 1: IF mb(amb, 0) = 0 THEN _CONTINUE
  264.             IF mx > mb(amb, 1) - .5 AND mx < mb(amb, 1) + .5 AND my > mb(amb, 2) - .5 AND my < mb(amb, 2) + .5 THEN crash_test = 1: EXIT FUNCTION
  265.         NEXT amb
  266.         FOR tx = 0 TO map_x - 1: FOR ty = 0 TO map_y - 1: IF map(tx, ty) = 0 THEN _CONTINUE
  267.                 IF mx > tx - .5 AND mx < tx + .5 AND my > ty - .5 AND my < ty + .5 THEN crash_test = 1: EXIT FUNCTION
  268.     NEXT ty, tx, myp
  269.  
  270. SUB draw_brick_2d (x, y, relsize, col)
  271.     DIM x(3), y(3): xc = (x - me(0)) * size_block + .5: yc = (y - me(1)) * size_block + .5: rot = (-me(3) + 180) * pip180
  272.     rotate_2d xc, yc, rot: xc = xc + monx / 2: yc = yc + mony / 2: size = size_block * size_wall * .5 * relsize
  273.     FOR t = 0 TO 3: x(t) = size * -(SGN(t AND 1) * 2 - 1): y(t) = size * (ABS(t < 2) * 2 - 1)
  274.     rotate_2d x(t), y(t), rot: x(t) = INT(x(t) + xc): y(t) = INT(y(t) + yc): NEXT t
  275.  
  276.     IF col = -1 THEN COLOR _RGB32(256 * RND(1), 256 * RND(1), 256 * RND(1)) ELSE COLOR b_colors(col)
  277.     LINE (x(0), y(0))-(x(1), y(1)): LINE (x(3), y(3))-(x(1), y(1)): LINE (x(2), y(2))-(x(3), y(3)): LINE (x(0), y(0))-(x(2), y(2))
  278.  
  279.  
  280. SUB point_3d (x, y, z)
  281.     x = x - me(0): y = y - me(2): z = z - me(1)
  282.     rotate_2d x, z, -(me(3) + 180) * pip180: rotate_2d y, z, (me(4) + 180) * pip180
  283.     x = x * 100: y = y * 100: z = z * 100
  284.  
  285. SUB draw_brick_3d (x, y, text, relsize)
  286.     DIM p(7, 2), sq(3)
  287.     size = size_wall * .5 * relsize
  288.     FOR t = 0 TO 7
  289.         p(t, 0) = size * (SGN(t AND 1) * 2 - 1) + x: p(t, 2) = size * (SGN(t AND 2) * 2 - 1) + y: p(t, 1) = size * SGN(t AND 4) * 2
  290.         point_3d p(t, 0), p(t, 1), p(t, 2)
  291.     NEXT t
  292.     shdw = ABS(INT((p(0, 2) + p(1, 2) + p(2, 2) + p(3, 2)) / 4))
  293.     sq$ = "-0246-2367-3175-1054" 'cubes points make square "-0123-4567"
  294.     FOR t2 = 0 TO 3: FOR t3 = 0 TO 3: sq(t3) = VAL(MID$(sq$, 2 + t2 * 5 + t3, 1)): NEXT t3
  295.         atext = text_mb(text, shdw(shdw))
  296.         wtext = _WIDTH(atext) - 1: htext = _HEIGHT(atext) - 1
  297.         _MAPTRIANGLE (0, 0)-(wtext, 0)-(0, htext), atext TO(p(sq(0), 0), p(sq(0), 1), p(sq(0), 2))-(p(sq(1), 0), p(sq(1), 1), p(sq(1), 2))-(p(sq(2), 0), p(sq(2), 1), p(sq(2), 2)), , _SMOOTH
  298.         _MAPTRIANGLE (wtext, htext)-(wtext, 0)-(0, htext), atext TO(p(sq(3), 0), p(sq(3), 1), p(sq(3), 2))-(p(sq(1), 0), p(sq(1), 1), p(sq(1), 2))-(p(sq(2), 0), p(sq(2), 1), p(sq(2), 2)), , _SMOOTH
  299.     NEXT t2
  300.  
  301. SUB tile_3d (x, y)
  302.     DIM p(3, 2)
  303.     FOR t = 0 TO 3
  304.         p(t, 0) = x + (SGN(t AND 1) * 2 - 1) * .5: p(t, 2) = y + (SGN(t AND 2) * 2 - 1) * .5: p(t, 1) = 0
  305.         point_3d p(t, 0), p(t, 1), p(t, 2)
  306.     NEXT t
  307.     atext = text_mb(0, shdw(ABS(INT((p(0, 2) + p(1, 2) + p(2, 2) + p(3, 2)) / 4))))
  308.     wtext = _WIDTH(atext) - 1: htext = _HEIGHT(atext) - 1
  309.     _MAPTRIANGLE (0, 0)-(wtext, 0)-(0, htext), atext TO(p(0, 0), p(0, 1), p(0, 2))-(p(1, 0), p(1, 1), p(1, 2))-(p(2, 0), p(2, 1), p(2, 2)), , _SMOOTH
  310.     _MAPTRIANGLE (wtext, htext)-(wtext, 0)-(0, htext), atext TO(p(3, 0), p(3, 1), p(3, 2))-(p(1, 0), p(1, 1), p(1, 2))-(p(2, 0), p(2, 1), p(2, 2)), , _SMOOTH
  311.  
  312. SUB money_3d (x, y)
  313.     DIM p(3, 2)
  314.     ang = TIMER * 2
  315.     FOR t = 0 TO 3
  316.         ang = TIMER * 2 + _PI * (t AND 1): p(t, 0) = SIN(ang) * .5 + x: p(t, 2) = COS(ang) * .5 + y: p(t, 1) = SGN(t AND 2)
  317.         point_3d p(t, 0), p(t, 1), p(t, 2)
  318.     NEXT t
  319.     atext = text_money(INT(10 * RND(1)))
  320.     wtext = _WIDTH(atext) - 1: htext = _HEIGHT(atext) - 1
  321.     _MAPTRIANGLE (0, 0)-(wtext, 0)-(0, htext), atext TO(p(0, 0), p(0, 1), p(0, 2))-(p(1, 0), p(1, 1), p(1, 2))-(p(2, 0), p(2, 1), p(2, 2)), , _SMOOTH
  322.     _MAPTRIANGLE (wtext, htext)-(wtext, 0)-(0, htext), atext TO(p(3, 0), p(3, 1), p(3, 2))-(p(1, 0), p(1, 1), p(1, 2))-(p(2, 0), p(2, 1), p(2, 2)), , _SMOOTH
  323.  
  324.  
  325.  

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: courtesy cubes :)
« Reply #10 on: February 20, 2022, 05:50:15 am »
lots of small changes to make the graphics and enjoyment better

Code: QB64: [Select]
  1. 'MasterGy 2022
  2.  
  3. DIM SHARED size_block, size_wall, me(9), monx, mony, mb_c, map_x, map_y, crash_test_disable, shdw_c
  4. '----------------- settings ---------------------------------------------------------------------------------------------
  5.  
  6.  
  7.  
  8.  
  9. map_x = 30 'size map X
  10. map_y = 30 'size map Y
  11. speed_min = .03 'bricks minimum speed
  12. speed_max = .06 'bricks maximum speed
  13. money_c = 6 'money number what you find
  14. mb_c = 80 'maximum mover bricks in the map
  15. me_speed = .12 'my speed
  16. mouse_sens = 1
  17.  
  18.  
  19.  
  20.  
  21.  
  22. '------------------------------------------------------ advanced settings -------------------------------------------------------------
  23. add_wall_c = 4 'cross road-walls inside map
  24. walk_limit = 8 'walk limit outside map
  25. tile_marg = 5 'tiles outside near wall
  26. me(5) = .5 'the size of my extent relative to a brick (1=standard size)
  27. cheat_keys = 0 'enable cheat keys
  28. monx = 800: mony = INT(monx / _DESKTOPWIDTH * _DESKTOPHEIGHT)
  29. size_block = 20 '2d map draw start size
  30. size_wall = .9 'size percent size_block (1=standard)
  31. b_colors = 12 'brick colors
  32. shdw_c = 50 'mipmap
  33. '----------------------------------------------------------------------------------------
  34. DIM SHARED temp_color(9) AS _INTEGER64
  35. CONST pip180 = 3.141592 / 180
  36.  
  37. 'me install 'ME array params '0,1,2=X,Y,Z 3=angXY 4=angXZ 5'XY dimension
  38. me(0) = -1: me(1) = -1: me(2) = .4 'my start locate
  39. size = 100: temp = _NEWIMAGE(size, size, 32): _DEST temp: CLS 0, _RGB32(10, 10, 10): CIRCLE (size / 2, size / 2), size / 2 * size_wall, _RGB32(200, 200, 200)
  40. PAINT (size / 2, size / 2), _RGB32(200, 200, 200): _CLEARCOLOR _RGB32(10, 10, 10): me_text = _COPYIMAGE(temp, 33): _FREEIMAGE temp
  41.  
  42. 'shadows
  43. DIM SHARED shdw(16383) AS _BYTE: FOR t = 0 TO 16383: ashdw = INT((shdw_c - 1) * 0.0006 * t): IF ashdw > shdw_c - 1 THEN ashdw = shdw_c - 1
  44. shdw(t) = ashdw: NEXT t
  45.  
  46.  
  47. 'directions
  48. DIM d(3, 1) AS _BYTE: d(3, 1) = -1: d(0, 0) = 1: d(1, 1) = 1: d(2, 0) = -1: d(3, 1) = -1
  49.  
  50. DIM SHARED map(map_x - 1, map_y - 1), mb(mb_c - 1, 9)
  51.  
  52. 'make colors
  53. DIM SHARED b_colors(b_colors - 1) AS _INTEGER64: FOR t = 1 TO b_colors - 1: b_colors(t) = _RGB32(30 + 180 * RND(1), 30 + 180 * RND(1), 30 + 180 * RND(1)): NEXT t
  54. b_colors(0) = _RGB32(150, 20, 20) 'wall color
  55.  
  56. 'make textures
  57. marg = .12: tmax = 40: tmin = 40
  58. DIM SHARED text_mb(mb_c - 1, shdw_c - 1), text_wall(shdw_c - 1)
  59. FOR t = 0 TO shdw_c - 1: size = INT(tmax - (tmax - tmin) / (shdw_c - 1) * t): dark = 1 - 1 / (shdw_c - 1) * t
  60.     stand_temp = _NEWIMAGE(size, size, 32): _DEST stand_temp: CLS , _RGB32(50, 50, 50) 'frame color
  61.     LINE (size * marg, size * marg)-(size - size * marg, size - size * marg), _RGB32(180, 180, 180), BF: _SOURCE stand_temp
  62.     noise = 5 + 10 / (shdw_c - 1) * t
  63.     FOR tx = 0 TO size - 1: FOR ty = 0 TO size - 1: temp_color(0) = POINT(tx, ty)
  64.             PSET (tx, ty), _RGB32(_RED32(temp_color(0)) - noise / 2 * RND(1) * noise, _GREEN32(temp_color(0)) - noise / 2 * RND(1) * noise, _BLUE32(temp_color(0)) - noise / 2 * RND(1) * noise)
  65.     NEXT ty, tx
  66.  
  67.  
  68.     'make wall
  69.     FOR t2 = 0 TO b_colors - 1: temp = _COPYIMAGE(stand_temp, 32): _DEST temp
  70.         IF t2 = 0 THEN LINE (0, 0)-(size, size), _RGB32(50, 50, 50): LINE (size, 0)-(0, size), _RGB32(50, 50, 50) 'no mover wall
  71.         trans = _NEWIMAGE(5, 5, 32): _DEST trans: CLS , _RGBA32(_RED32(b_colors(t2)) * dark, _GREEN32(b_colors(t2)) * dark, _BLUE32(b_colors(t2)) * dark, 150)
  72.         _SOURCE trans: _DEST temp: _BLEND temp: _PUTIMAGE: _FREEIMAGE trans
  73.         trans = _NEWIMAGE(5, 5, 32): _DEST trans: CLS , _RGBA32(0, 0, 0, (1 - dark) * 255)
  74.         _SOURCE trans: _DEST temp: _PUTIMAGE: _FREEIMAGE trans
  75.     text_mb(t2, t) = _COPYIMAGE(temp, 33): _FREEIMAGE temp: NEXT t2: _FREEIMAGE stand_temp
  76.  
  77.  
  78. 'skys_color
  79. DIM text_sky(999)
  80.  
  81.  
  82. FOR t = 0 TO 499
  83.     temp = _NEWIMAGE(3, 3, 32): _DEST temp: CLS , _RGB32(20, 20, 255 / 499 * t): text_sky(t) = _COPYIMAGE(temp, 33): _FREEIMAGE temp
  84.  
  85. 'make walls
  86. FOR tx = 0 TO map_x - 1: FOR ty = 0 TO map_y - 1: map(tx, ty) = ABS(tx = 0 OR ty = 0 OR tx = map_x - 1 OR ty = map_y - 1): NEXT ty, tx
  87.  
  88. 'add walls within the framework
  89. add_wall_p(0) = .8: add_wall_p(1) = .8: FOR t = 1 TO add_wall_c
  90.     DO: FOR t2 = 0 TO 3: p(t2) = map_x * add_wall_p(t2 MOD 2) * RND(1) + map_x * (1 - add_wall_p(t2 MOD 2)) / 2: NEXT t2
  91.     dis = SQR((p(0) - p(2)) ^ 2 + (p(1) - p(3)) ^ 2): LOOP WHILE dis < 5: dis = dis * .7
  92. FOR t2 = 0 TO dis: map(INT(p(0) + (p(2) - p(0)) / dis * t2), INT(p(1) + (p(3) - p(1)) / dis * t2)) = 2: NEXT t2, t
  93.  
  94.  
  95. 'money install
  96. DIM SHARED text_money(9)
  97. FOR t = 0 TO 9: temp = _NEWIMAGE(8, 16, 32): _DEST temp: COLOR _RGB32(256 * RND(1), 256 * RND(1), 256 * RND(1)): PRINT "$";
  98. _CLEARCOLOR _RGB32(0, 0, 0): text_money(t) = _COPYIMAGE(temp, 33): _FREEIMAGE temp: NEXT t
  99. DIM money(money_c - 1, 9)
  100. FOR t = 0 TO money_c - 1: DO: money(t, 0) = INT(1 + (map_x - 2) * RND(1)): money(t, 1) = INT(1 + (map_y - 2) * RND(1))
  101. LOOP WHILE map(money(t, 0), money(t, 1)): map(money(t, 0), money(t, 1)) = 3: NEXT t
  102.  
  103. 'make mover bricks
  104. FOR t = 0 TO mb_c - 1: agent_timer = TIMER
  105.     DO: mb(t, 1) = INT(1 + (map_x - 2) * RND(1)): mb(t, 2) = INT(1 + (map_y - 2) * RND(1)): mb(t, 3) = INT(4 * RND(1)): busy = 0
  106.         FOR tx = -1 TO 1: FOR ty = -1 TO 1: busy = busy OR SGN(map(tx + mb(t, 1), ty + mb(t, 2))): NEXT ty, tx
  107.         FOR t2 = 0 TO mb_c - 1: IF mb(t2, 0) = 0 OR busy THEN _CONTINUE
  108.         busy = busy OR (SQR((mb(t2, 1) - mb(t, 1)) ^ 2 + (mb(t2, 2) - mb(t, 2)) ^ 2) < 2): NEXT t2: IF ABS(agent_timer - TIMER) > 2 THEN EXIT FOR
  109.     LOOP WHILE busy: mb(t, 0) = 1: mb(t, 5) = 1 + INT((b_colors - 1) * RND(1))
  110.     mb(t, 6) = speed_min + (speed_max - speed_min) * RND(1)
  111.  
  112.  
  113.  
  114. 'entri brick to the area
  115. t = INT(2 * RND(1)): posx = INT((1 + (map_x - 2) * RND(1)) * t) + INT(2 * RND(1)) * (map_x - 1) * ABS(t = 0)
  116. posy = INT((1 + (map_y - 2) * RND(1)) * (t XOR 1)) + INT(2 * RND(1)) * (map_x - 1) * ABS((t XOR 1) = 0): map(posx, posy) = 0
  117.  
  118.  
  119.  
  120.  
  121. 'mb array
  122. '0 ena/disa
  123. '1,2 XY location
  124. '3 'direction
  125. '4 stop counter
  126. '5 color index
  127. '6 speed
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137. limit_cycle = 1
  138. '------------------------------------------- BOSS CYCLE
  139. DO: IF limit_cycle THEN _LIMIT 30
  140.     draw_2d_map = _KEYDOWN(100306) OR _KEYDOWN(100305) 'if press CTRL, show the 2d map
  141.  
  142.     'draw non mover blocks
  143.  
  144.  
  145.     FOR tx = -tile_marg TO map_x - 1 + tile_marg: FOR ty = -tile_marg TO map_y - 1 + tile_marg
  146.             IF tx < 0 OR tx > map_x - 1 OR ty < 0 OR ty > map_y - 1 THEN
  147.  
  148.             ELSE
  149.                 IF map(tx, ty) = 1 OR map(tx, ty) = 2 THEN
  150.                     IF draw_2d_map THEN draw_brick_2d tx, ty, 1, 0
  151.                     draw_brick_3d tx, ty, 0, 1
  152.                 ELSE
  153.  
  154.                 END IF
  155.             END IF
  156.             tile_3d tx, ty
  157.     NEXT ty, tx
  158.  
  159.     'draw mover blocks
  160.     FOR amb = 0 TO mb_c - 1:
  161.         IF mb(amb, 0) THEN
  162.             IF draw_2d_map THEN draw_brick_2d mb(amb, 1), mb(amb, 2), 1, mb(amb, 5)
  163.             draw_brick_3d mb(amb, 1), mb(amb, 2), mb(amb, 5), 1
  164.         END IF
  165.     NEXT amb
  166.  
  167.     'draw me
  168.     IF (dead = 0 OR (dead AND INT(2 * RND(1)))) AND draw_2d_map THEN draw_brick_2d me(0), me(1), me(5), mb(0, 0)
  169.  
  170.     'draw money
  171.     IF storyline = 0 THEN
  172.         FOR t = 0 TO money_c - 1: IF money(t, 2) THEN _CONTINUE
  173.             IF draw_2d_map THEN draw_brick_2d money(t, 0), money(t, 1), 1, -1
  174.             money_3d money(t, 0), money(t, 1)
  175.         NEXT t
  176.     END IF
  177.  
  178.     'moving mover bricks
  179.     FOR amb = 0 TO mb_c - 1: IF mb(amb, 0) = 0 THEN _CONTINUE
  180.         p(0) = CINT(mb(amb, 1) + d(mb(amb, 3), 0) * (mb(amb, 6) + .5))
  181.         p(1) = CINT(mb(amb, 2) + d(mb(amb, 3), 1) * (mb(amb, 6) + .5)): dontgo = 0: letsneg = 0
  182.  
  183.         FOR t = 0 TO mb_c - 1: IF mb(t, 0) = 0 OR t = amb OR dontgo THEN _CONTINUE
  184.             vr = mb(t, 3) MOD 2: vr2 = vr = (mb(amb, 3) MOD 2)
  185.             letsneg = letsneg OR (((ABS(mb(t, 1 + vr) - mb(amb, 1 + vr)) < 1) AND (mb(t, 1 + (vr XOR 1))) = (mb(amb, 1 + (vr XOR 1)))) AND vr2)
  186.             dontgo = dontgo OR ((ABS(p(0) - mb(t, 1)) < 1 AND ABS(p(1) - mb(t, 2)) < 1) AND (vr2 = 0))
  187.         NEXT t
  188.  
  189.         mb(amb, 3) = (mb(amb, 3) + ABS(((letsneg) OR map(p(0), p(1)) = 2 OR map(p(0), p(1)) = 3) OR (p(0) = 0 OR p(0) = map_x - 1 OR p(1) = 0 OR p(1) = map_y - 1)) * 2) MOD 4
  190.         mb(amb, 4) = (mb(amb, 4) + ABS(dontgo)) * ABS(dontgo)
  191.         mb(amb, 3) = (mb(amb, 3) + 2 * ABS((mb(amb, 4) > 5 / mb(amb, 6)) AND dontgo)) MOD 4
  192.         mb(amb, 1) = mb(amb, 1) + d(mb(amb, 3), 0) * mb(amb, 6) * ABS(dontgo = 0)
  193.         mb(amb, 2) = mb(amb, 2) + d(mb(amb, 3), 1) * mb(amb, 6) * ABS(dontgo = 0)
  194.  
  195.  
  196.     NEXT amb
  197.  
  198.     'control me
  199.     mousex = 0: mousey = 0: mw = 0: WHILE _MOUSEINPUT: mousex = mousex + _MOUSEMOVEMENTX: mousey = mousey + _MOUSEMOVEMENTY: mw = mw + _MOUSEWHEEL: WEND
  200.     k_left = _KEYDOWN(19200) OR _KEYDOWN(ASC("a")): k_right = _KEYDOWN(19712) OR _KEYDOWN(ASC("d"))
  201.     k_up = _KEYDOWN(18432) OR _KEYDOWN(ASC("w")) OR _MOUSEBUTTON(1): k_down = _KEYDOWN(20480) OR _KEYDOWN(ASC("s"))
  202.  
  203.     me(3) = me(3) + mousex * mouse_sens '* ABS((_KEYDOWN(19200) OR _KEYDOWN(19712) OR _KEYDOWN(18432) OR _KEYDOWN(20480)) = 0)
  204.     me(4) = me(4) + mousey * mouse_sens: IF ABS(me(4)) > 80 THEN me(4) = 80 * SGN(me(4))
  205.     size_block = size_block - mw: IF size_block < 3 THEN size_block = 3 ELSE IF size_block > 140 THEN size_block = 140
  206.  
  207.     IF dead = 0 THEN
  208.         IF crash_test(me(0), me(1)) THEN
  209.             try_speed = speed_max * 1.1
  210.             try = -1: FOR atry = 0 TO 3
  211.                 IF crash_test(me(0) + d(atry, 0) * try_speed, me(1) + d(atry, 1) * try_speed) = 0 THEN try = atry: EXIT FOR
  212.             NEXT atry: IF try = -1 THEN dead = 1
  213.             IF dead = 0 THEN me(0) = me(0) + d(atry, 0) * try_speed: me(1) = me(1) + d(atry, 1) * try_speed
  214.         END IF
  215.         try_ang_sc = 85
  216.         FOR try_ang = 0 TO try_ang_sc STEP 6: FOR try_ang_dir = 0 TO 1
  217.                 go = me_speed * ABS(k_left OR k_right OR k_up OR k_down) * (1 / try_ang_sc * (try_ang_sc - try_ang)) ^ .7
  218.                 go_ang = k_down * 180 + 90 * (k_left - k_right) + me(3) + (try_ang_dir * 2 - 1) * try_ang
  219.                 go_x = SIN(go_ang * pip180) * go + me(0): go_y = -COS(go_ang * pip180) * go + me(1)
  220.                 walk_limit_ok = (go_x < -walk_limit OR go_y < -walk_limit OR go_x > map_x - 1 + walk_limit OR go_y > map_y - 1 + walk_limit) = 0
  221.                 IF crash_test(go_x, go_y) = 0 AND walk_limit_ok THEN me(0) = go_x: me(1) = go_y: GOTO ok
  222.         NEXT try_ang_dir, try_ang
  223.         ok:
  224.  
  225.     END IF
  226.  
  227.     'cheats
  228.     inkey2$ = INKEY$: IF inkey2$ = CHR$(27) THEN SYSTEM
  229.     IF cheat_keys THEN
  230.         IF inkey2$ = "r" THEN RUN
  231.         IF inkey2$ = "l" THEN limit_cycle = limit_cycle XOR 1
  232.         IF inkey2$ = "c" THEN crash_test_disable = crash_test_disable XOR 1
  233.         IF inkey2$ = "o" THEN dead = 1 'reborn
  234.         IF inkey2$ = "p" THEN dead = 0 'dead
  235.     END IF
  236.     'sky draw
  237.     sky_flash = sky_flash - 0.02: IF sky_flash < 0 THEN sky_flash = 0
  238.     IF sky_flash > 1 THEN sky_flash = 1
  239.     IF dead THEN sky_ind = 490 * SGN(INT(TIMER * 50) AND 1) ELSE sky_ind = INT(490 * sky_flash)
  240.     asky = text_sky(sky_ind)
  241.     _MAPTRIANGLE (0, 0)-(0, 5)-(5, 0), asky TO(-16000, -16000, -10000)-(16000, -16000, -10000)-(-16000, 16000, -10000)
  242.     _MAPTRIANGLE (0, 0)-(0, 5)-(5, 0), asky TO(16000, 16000, -10000)-(16000, -16000, -10000)-(-16000, 16000, -10000)
  243.     _DISPLAY: CLS
  244.  
  245.     'money near- storyline
  246.     IF storyline = 0 THEN
  247.         FOR t = 0 TO money_c - 1
  248.             find_money = SQR((me(0) - money(t, 0)) ^ 2 + (me(1) - money(t, 1)) ^ 2) < 1.1 AND (money(t, 2) = 0)
  249.             IF find_money THEN money_sum = money_sum + 1: map(money(t, 0), money(t, 1)) = 0: money(t, 2) = 1: sky_flash = 1
  250.         NEXT t
  251.         storyline = storyline + ABS(money_sum = money_c)
  252.     END IF
  253.     IF storyline = 1 AND (me(0) > 0 AND me(0) < map_x - 1 AND me(1) > 0 AND me(1) < map_y - 1) = 0 THEN storyline = 2
  254.  
  255.     SELECT CASE storyline
  256.         CASE 0: s$ = "GET THE MONEY !   " + STR$(money_c) + " /" + STR$(money_sum)
  257.         CASE 1: s$ = "ESCAPE OUTSIDE THE WALL !"
  258.         CASE 2: s$ = "Mission compeleted ! "
  259.     END SELECT
  260.  
  261.     IF dead THEN s$ = "you dead ,mission incompleted !"
  262.  
  263.     COLOR _RGB32(255 * RND(1), 255 * RND(1), 255 * RND(1)): LOCATE 3, (monx / 8 - LEN(s$)) / 2: PRINT s$
  264.     IF draw_2d_map = 0 THEN COLOR _RGB32(255, 255, 255), _RGBA(0, 0, 0, 0): LOCATE mony / 16 - 1, 1: PRINT "CTRL - show 2Dmap        mouse wheel:2Dmap zoom";
  265.  
  266.  
  267. SUB rotate_2d (x, y, ang): x1 = -(x * COS(ang) - y * SIN(ang)): y1 = -(x * SIN(ang) + y * COS(ang)): x = x1: y = y1: END SUB
  268.  
  269. FUNCTION crash_test (x, y): IF crash_test_disable THEN EXIT FUNCTION
  270.  
  271.     FOR myp = 0 TO 3: mx = x + me(5) * .5 * (SGN(myp AND 1) * 2 - 1): my = y + me(5) * .5 * (SGN(myp AND 2) * 2 - 1)
  272.         FOR amb = 0 TO mb_c - 1: IF mb(amb, 0) = 0 THEN _CONTINUE
  273.             IF mx > mb(amb, 1) - .5 AND mx < mb(amb, 1) + .5 AND my > mb(amb, 2) - .5 AND my < mb(amb, 2) + .5 THEN crash_test = 1: EXIT FUNCTION
  274.         NEXT amb
  275.         FOR tx = 0 TO map_x - 1: FOR ty = 0 TO map_y - 1: IF map(tx, ty) = 0 THEN _CONTINUE
  276.                 IF mx > tx - .5 AND mx < tx + .5 AND my > ty - .5 AND my < ty + .5 THEN crash_test = 1: EXIT FUNCTION
  277.     NEXT ty, tx, myp
  278.  
  279. SUB draw_brick_2d (x, y, relsize, col)
  280.     DIM x(3), y(3): xc = (x - me(0)) * size_block + .5: yc = (y - me(1)) * size_block + .5: rot = (-me(3) + 180) * pip180
  281.     rotate_2d xc, yc, rot: xc = xc + monx / 2: yc = yc + mony / 2: size = size_block * size_wall * .5 * relsize
  282.     FOR t = 0 TO 3: x(t) = size * -(SGN(t AND 1) * 2 - 1): y(t) = size * (ABS(t < 2) * 2 - 1)
  283.     rotate_2d x(t), y(t), rot: x(t) = INT(x(t) + xc): y(t) = INT(y(t) + yc): NEXT t
  284.     IF col = -1 THEN COLOR _RGB32(256 * RND(1), 256 * RND(1), 256 * RND(1)) ELSE COLOR b_colors(col)
  285.     LINE (x(0), y(0))-(x(1), y(1)): LINE (x(3), y(3))-(x(1), y(1)): LINE (x(2), y(2))-(x(3), y(3)): LINE (x(0), y(0))-(x(2), y(2))
  286.     IF col = -1 THEN PAINT ((x(0) + x(3)) / 2, (y(0) + y(3)) / 2)
  287.  
  288.  
  289.  
  290. SUB point_3d (x, y, z)
  291.     x = x - me(0): y = y - me(2): z = z - me(1): rotate_2d x, z, -(me(3) + 180) * pip180: rotate_2d y, z, (me(4) + 180) * pip180
  292.     x = x * 100: y = y * 100: z = z * 100
  293.  
  294. SUB draw_brick_3d (x, y, text, relsize)
  295.     DIM p(3, 2), pc(7, 2), sq(3)
  296.     size = size_wall * .5 * relsize
  297.     FOR t = 0 TO 7
  298.         pc(t, 0) = size * (SGN(t AND 1) * 2 - 1) + x: pc(t, 2) = size * (SGN(t AND 2) * 2 - 1) + y: pc(t, 1) = size * SGN(t AND 4) * 2
  299.         point_3d pc(t, 0), pc(t, 1), pc(t, 2)
  300.     NEXT t
  301.  
  302.     FOR t = 0 TO 3
  303.         FOR t2 = 0 TO 3: side = VAL(MID$("-0246-2367-3175-1054", 2 + t * 5 + t2, 1))
  304.         FOR t3 = 0 TO 2: p(t2, t3) = pc(side, t3): NEXT t3, t2
  305.         draw_square p(), text_mb(text, shdw(ABS(INT((p(0, 2) + p(1, 2) + p(2, 2) + p(3, 2)) / 4))))
  306.     NEXT t
  307.  
  308. SUB tile_3d (x, y)
  309.     DIM p(3, 2)
  310.     FOR t = 0 TO 3
  311.         p(t, 0) = x + (SGN(t AND 1) * 2 - 1) * .5: p(t, 2) = y + (SGN(t AND 2) * 2 - 1) * .5: p(t, 1) = 0
  312.         point_3d p(t, 0), p(t, 1), p(t, 2)
  313.     NEXT t
  314.     draw_square p(), text_mb(0, shdw(ABS(INT((p(0, 2) + p(1, 2) + p(2, 2) + p(3, 2)) / 4))))
  315.  
  316. SUB money_3d (x, y)
  317.     DIM p(3, 2): ang = TIMER * 2
  318.     FOR t = 0 TO 3
  319.         ang = (TIMER * 2 + _PI * (t AND 1) + x + y) * (((x + y) AND 1) * 2 - 1)
  320.         p(t, 0) = SIN(ang) * .5 + x: p(t, 2) = COS(ang) * .5 + y: p(t, 1) = SGN(t AND 2)
  321.         point_3d p(t, 0), p(t, 1), p(t, 2)
  322.     NEXT t
  323.     draw_square p(), text_money(INT(10 * RND(1)))
  324.  
  325. SUB draw_square (p(), text)
  326.     wtext = _WIDTH(text) - 1: htext = _HEIGHT(text) - 1
  327.     _MAPTRIANGLE (0, 0)-(wtext, 0)-(0, htext), text TO(p(0, 0), p(0, 1), p(0, 2))-(p(1, 0), p(1, 1), p(1, 2))-(p(2, 0), p(2, 1), p(2, 2)), , _SMOOTH
  328.     _MAPTRIANGLE (wtext, htext)-(wtext, 0)-(0, htext), text TO(p(3, 0), p(3, 1), p(3, 2))-(p(1, 0), p(1, 1), p(1, 2))-(p(2, 0), p(2, 1), p(2, 2)), , _SMOOTH
  329.  
  330.  
  331.  
« Last Edit: February 20, 2022, 05:57:37 am by MasterGy »