Author Topic: Mover Bricks 2D and 3D  (Read 6122 times)

0 Members and 1 Guest are viewing this topic.

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Mover Bricks 2D and 3D
« on: February 21, 2022, 03:46:47 pm »
Hello !

The game is complete, it does not use external files. At start-up, the difficulty level can be adjusted (1-5).
I could still increase the design, but it wasn’t my goal with all this to make a design game, so I won’t deal with it anymore.
I was wondering how many of you make games. You make very good 2D games. I especially like walking games.A small change can be made from these games into a 3D game.

The program would ultimately be a demonstration. At the end of the source code, those few lines perform the 3D calculations.
You need a 3D coordinate system, you need to include many points (many points form textures), and you need a point in this space who is an "observer." This is the most important ! The observer! Who looks at the other points. The observer has 5 data. X, Y, Z coordinates and direction to look. This is the angle of 2 planes perpendicular to each other. So X, Y, Z, ALPHA, BETA Knowing this, you can calculate the projected position of all the points on the screen, and _maptriangle can come.
I was thinking of a 3d engine that anyone could easily try based on their own ideas, but since the whole thing would be about 5 lines, I figured out instead that I would try to describe it as simply as possible to make it understandable.
A short, perfectly understandable writing about this. Put 2d theory and 3D projection on one level! It's a lot simpler than it looks.
Next time, I’ll check to see if a lot of people get to deal with it.



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

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: Mover Bricks 2D and 3D
« Reply #1 on: February 21, 2022, 04:07:02 pm »
This is brilliant. You're in a class of your own, Master. Your works are loved by many, FEARED by many more.
You're not done when it works, you're done when it's right.

Offline dbox

  • Newbie
  • Posts: 80
    • View Profile
Re: Mover Bricks 2D and 3D
« Reply #2 on: February 21, 2022, 04:33:14 pm »
I got the money!  @MasterGy this is extremely impressive.  It's pretty remarkable the projects you've been able to do just using _MapTriangle.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Mover Bricks 2D and 3D
« Reply #3 on: February 21, 2022, 06:37:47 pm »
Fascinating. Even the Vulcan Science Academy is interested in your work!
Logic is the beginning of wisdom.

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Mover Bricks 2D and 3D
« Reply #4 on: February 22, 2022, 09:25:37 am »
Awesome work, @MasterGy!

- Dav

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: Mover Bricks 2D and 3D
« Reply #5 on: February 22, 2022, 02:41:50 pm »
Thanks for trying it!

Thanks STxAxTIC and Dav, good praise!

Dbox. That's interesting. Extremely I didn't even succeed. I deliberately made it hard for no one to succeed!

Johnno56 "Vulcan Science Academy". What's that  ? :)

Offline dbox

  • Newbie
  • Posts: 80
    • View Profile
Re: Mover Bricks 2D and 3D
« Reply #6 on: February 22, 2022, 02:55:24 pm »
Well, I did play with option 2 - Easy.  Mostly in top-down mode.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Mover Bricks 2D and 3D
« Reply #7 on: February 22, 2022, 05:17:26 pm »
@MasterGy "What's that?"

I am obviously in error for not stating my point more clearly. My apologies.

To keep it short... It's a Star Trek thing... Follow https://startrekdesignproject.com/symbols/vulcan-science-academy-vsa/ then the link to "Memory Alpha". If you have any further questions, feel free to ask...

Regards

J
Logic is the beginning of wisdom.

Offline madscijr

  • Seasoned Forum Regular
  • Posts: 295
    • View Profile
Re: Mover Bricks 2D and 3D
« Reply #8 on: April 01, 2022, 03:24:48 pm »
Hello !

The game is complete, it does not use external files. At start-up, the difficulty level can be adjusted (1-5).
I could still increase the design, but it wasn’t my goal with all this to make a design game, so I won’t deal with it anymore.
I was wondering how many of you make games. You make very good 2D games. I especially like walking games.A small change can be made from these games into a 3D game.

I love the idea of giving the user the option to play a game in 2-D, 2.5D or 3-D or switching between these views while they play. I'll definitely give this a look!