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
'----------------- settings ---------------------------------------------------------------------------------------------
PRINT "MOVER BRICK game (MasterGy 2022)" PRINT "Choise level ! Press key 1,2,3,4,5" PRINT "(1-no move bricks 2-easy 3-medium 4-high 5-extreme)" 'LEVEL = 3
map_x = 30 'size map X
map_y = 30 'size map Y
money_c = 10 'money number what you find
mb_c = 90 'maximum mover bricks in the map
me_speed = .12 'my speed
mouse_sens = 1
'------------------------------------------------------ advanced settings -------------------------------------------------------------
add_wall_c = 4 'cross road-walls inside map
walk_limit = 8 'walk limit outside map
tile_marg = 5 'tiles outside near wall
me(5) = .5 'the size of my extent relative to a brick (1=standard size)
cheat_keys = 0 'enable cheat keys
size_wall = .9 'size percent size_block (1=standard)
b_colors = 12 'brick colors
shdw_c = 50 'mipmap
speed_max = .11 * LEVEL / 4 'bricks maximum speed
speed_min = speed_max * .7 'bricks minimum speed
zoom_2d = .8
'----------------------------------------------------------------------------------------
'ARRAYS
'MB array 0-ena/disa 1,2-XYlocation 3-direction 4-stopcounter 5-colorindex 6-relativespeed 7-levelratiospeed
'MAP array 0-empty 1-wall 2-wall-crossroad 3-money
'ME/CAM array '0,1,2-X,Y,Z 3=angXY 4=angXZ 5'XY dimension
CONST pip180
= 3.141592 / 180
'ME install
me(0) = -1: me(1) = -1 'my start locate
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)
'shadows
ashdw
= INT((shdw_c
- 1) * 0.0006 * t
):
IF ashdw
> shdw_c
- 1 THEN ashdw
= shdw_c
- 1 shdw(t) = ashdw
'directions
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
'make colors
b_colors
(0) = _RGB32(150, 20, 20) 'wall color
'make textures
marg = .12: tmax = 40: tmin = 40
DIM SHARED text_mb
(mb_c
- 1, shdw_c
- 1), text_wall
(shdw_c
- 1) FOR t
= 0 TO shdw_c
- 1: size
= INT(tmax
- (tmax
- tmin
) / (shdw_c
- 1) * t
): dark
= 1 - 1 / (shdw_c
- 1) * t
LINE (size
* marg
, size
* marg
)-(size
- size
* marg
, size
- size
* marg
), _RGB32(180, 180, 180), BF:
_SOURCE stand_temp
noise = 5 + 5 * (1 / (shdw_c - 1) * t) ^ 1.2 'add noise far tiles
FOR tx
= 0 TO size
- 1:
FOR ty
= 0 TO size
- 1: temp_color
(0) = POINT(tx
, ty
)
'make wall
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
'skys_color
'make walls
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
'add walls within the framework
add_wall_p
(0) = .8: add_wall_p
(1) = .8:
FOR t
= 1 TO add_wall_c
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
dis
= SQR((p
(0) - p
(2)) ^ 2 + (p
(1) - p
(3)) ^ 2):
LOOP WHILE dis
< 5: dis
= dis
* .7FOR 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
'money install
DIM money
(money_c
- 1, 9) 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)) LOOP WHILE map
(money
(t
, 0), money
(t
, 1)): map
(money
(t
, 0), money
(t
, 1)) = 3:
NEXT t
'make mover bricks
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 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
'entri brick to the area
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
limit_cycle = 1
'------------------------------------------- BOSS CYCLE
'draw non mover blocks
FOR tx
= -tile_marg
TO map_x
- 1 + tile_marg:
FOR ty
= -tile_marg
TO map_y
- 1 + tile_marg
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 tile_3d tx, ty
'draw mover blocks
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
'draw me
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)
'draw money
FOR t
= 0 TO money_c
- 1:
IF money
(t
, 2) = 0 THEN money_3d money
(t
, 0), money
(t
, 1)
'moving mover bricks
p
(0) = CINT(mb
(amb
, 1) + d
(mb
(amb
, 3), 0) * (mb
(amb
, 6) + .5)) p
(1) = CINT(mb
(amb
, 2) + d
(mb
(amb
, 3), 1) * (mb
(amb
, 6) + .5)): dontgo
= 0: letsneg
= 0
vr
= mb
(t
, 3) MOD 2: vr2
= vr
= (mb
(amb
, 3) MOD 2) 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
) dontgo
= dontgo
OR ((ABS(p
(0) - mb
(t
, 1)) < 1 AND ABS(p
(1) - mb
(t
, 2)) < 1) AND (vr2
= 0)):
NEXT t
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 mb
(amb
, 4) = (mb
(amb
, 4) + ABS(dontgo
)) * ABS(dontgo
) mb
(amb
, 3) = (mb
(amb
, 3) + 2 * ABS((mb
(amb
, 4) > 5 / mb
(amb
, 6)) AND dontgo
)) MOD 4 mb
(amb
, 1) = mb
(amb
, 1) + d
(mb
(amb
, 3), 0) * mb
(amb
, 6) * ABS(dontgo
= 0) mb
(amb
, 2) = mb
(amb
, 2) + d
(mb
(amb
, 3), 1) * mb
(amb
, 6) * ABS(dontgo
= 0)
'control me
mouse_act_sens
= mouse_sens
* (1 - (zoom_3d
* .9) * ABS(draw_2d_map
= 0)) me
(3) = me
(3) + mousex
* mouse_act_sens
- INT(me
(3) / 360) * 360 me(4) = me(4) + mousey * mouse_act_sens
d2m_ang
= INT((me
(3) + 45) / 90) * 90 zoom_2d = zoom_2d + zoom_change * draw_2d_map
zoom_3d = zoom_3d + zoom_change * (draw_2d_map = 0)
IF crash_test
(me
(0), me
(1)) THEN try_speed = speed_max * 1.1
try
= -1:
FOR atry
= 0 TO 3 IF crash_test
(me
(0) + d
(atry
, 0) * try_speed
, me
(1) + d
(atry
, 1) * try_speed
) = 0 THEN try
= atry:
EXIT FOR IF dead
= 0 THEN me
(0) = me
(0) + d
(atry
, 0) * try_speed: me
(1) = me
(1) + d
(atry
, 1) * try_speed
try_ang_sc = 85
go
= me_speed
* ABS((k_left
+ k_right
+ k_up
+ k_down
) = -1) * (1 / try_ang_sc
* (try_ang_sc
- try_ang
)) ^ .7 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
go_x
= SIN(go_ang
* pip180
) * go
+ me
(0): go_y
= -COS(go_ang
* pip180
) * go
+ me
(1) 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 IF crash_test
(go_x
, go_y
) = 0 AND walk_limit_ok
THEN me
(0) = go_x: me
(1) = go_y:
GOTO ok
NEXT try_ang_dir
, try_ang
ok:
'cheats
IF inkey2$
= "l" THEN limit_cycle
= limit_cycle
XOR 1 IF inkey2$
= "c" THEN crash_test_disable
= crash_test_disable
XOR 1 IF inkey2$
= "o" THEN dead
= 1 'reborn IF inkey2$
= "p" THEN dead
= 0 'dead
'sky draw
sky_flash
= sky_flash
- 0.02:
IF sky_flash
< 0 THEN sky_flash
= 0 IF sky_flash
> 1 THEN sky_flash
= 1 asky = text_sky(sky_ind)
_MAPTRIANGLE (0, 0)-(0, 5)-(5, 0), asky
TO(-16000, -16000, -10000)-(16000, -16000, -10000)-(-16000, 16000, -10000) _MAPTRIANGLE (0, 0)-(0, 5)-(5, 0), asky
TO(16000, 16000, -10000)-(16000, -16000, -10000)-(-16000, 16000, -10000)
'STORYLINE
find_money
= SQR((me
(0) - money
(t
, 0)) ^ 2 + (me
(1) - money
(t
, 1)) ^ 2) < 1.1 AND (money
(t
, 2) = 0) 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
storyline
= storyline
+ ABS(money_sum
= money_c
) 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
CASE 0: s$
= "GET THE MONEY ! " + STR$(money_c
) + " /" + STR$(money_sum
) CASE 1: s$
= "ESCAPE OUTSIDE THE WALL !" CASE 2: s$
= "Mission compeleted ! " IF dead
THEN s$
= "you dead ,mission incompleted !"
PRINT "Switch 2D to 3D- space-key control: arrows 2D zoom: mouse wheel (";
INT(zoom_2d
* 100);
"%)" PRINT "Switch 3D to 2D- space-key control: WASD + mouse 3D zoom: mouse wheel (";
INT(zoom_3d
* 100);
"%)"
'camera fresh
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
cam(0) = cam(0) + (me(0) - cam(0)) * 0.1
cam(1) = cam(1) + (me(1) - cam(1)) * 0.1
cam(2) = cam(2) + ((1.1 + (1 - zoom_2d) * 40) - cam(2)) * 0.1
cam(3) = cam(3) + (d2m_ang - cam(3)) * 0.5
cam(4) = cam(4) + (90 - cam(4)) * 0.1
cam(0) = me(0)
cam(1) = me(1)
cam(3) = me(3)
cam
(4) = cam
(4) + (me
(4) - cam
(4)) * (0.05 + 0.45 * ABS(ABS(me
(2) - cam
(2)) < .5)) cam(2) = cam(2) + (0.3 - cam(2)) * 0.1
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
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)
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
x
= x
* 100: y
= y
* 100: z
= z
* (120 - ABS(draw_2d_map
= 0) * zoom_3d
* 115)
SUB draw_brick_3d
(x
, y
, text
, relsize
) size = size_wall * .5 * relsize
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 point_3d pc(t, 0), pc(t, 1), pc(t, 2)
FOR t2
= 0 TO 3: side
= VAL(MID$("-0246-2367-3175-1054-4567", 2 + t
* 5 + t2
, 1)) FOR t3
= 0 TO 2: p
(t2
, t3
) = pc
(side
, t3
):
NEXT t3
, t2
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)))
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 point_3d p(t, 0), p(t, 1), p(t, 2)
IF draw_2d_map
THEN shdw
= 1000 ELSE shdw
= ABS(INT((p
(0, 2) + p
(1, 2) + p
(2, 2) + p
(3, 2)) / 4)) draw_square p(), text_mb(0, shdw(shdw))
ang
= (TIMER * 2 + _PI * (t
AND 1) + x
+ y
) * (((x
+ y
) AND 1) * 2 - 1) p
(t
, 0) = SIN(ang
) * .5: p
(t
, 2) = COS(ang
) * .5: p
(t
, 1) = SGN(t
AND 2) 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 p(t, 0) = p(t, 0) + x: p(t, 2) = p(t, 2) + y
point_3d p(t, 0), p(t, 1), p(t, 2)
draw_square p
(), text_money
(INT(10 * RND(1)))
SUB draw_square
(p
(), text
) _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 _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
SUB set_speed_bricks
(set_speed
) 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