'MasterGy 2022
DIM SHARED size_block
, size_wall
, me
(9), monx
, mony
, mb_c
, map_x
, map_y
, crash_test_disable
, shdw_c
'----------------- settings ---------------------------------------------------------------------------------------------
map_x = 30 'size map X
map_y = 30 'size map Y
speed_min = .03 'bricks minimum speed
speed_max = .06 'bricks maximum speed
money_c = 6 'money number what you find
mb_c = 80 '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_block = 20 '2d map draw start size
size_wall = .9 'size percent size_block (1=standard)
b_colors = 12 'brick colors
shdw_c = 50 'mipmap
'----------------------------------------------------------------------------------------
CONST pip180
= 3.141592 / 180
'me install 'ME array params '0,1,2=X,Y,Z 3=angXY 4=angXZ 5'XY dimension
me(0) = -1: me(1) = -1: me(2) = .4 '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
'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
DIM SHARED map
(map_x
- 1, map_y
- 1), mb
(mb_c
- 1, 9)
'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 + 10 / (shdw_c - 1) * t
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: busy
= busy
OR SGN(map
(tx
+ mb
(t
, 1), ty
+ mb
(t
, 2))):
NEXT ty
, tx
mb
(t
, 6) = speed_min
+ (speed_max
- speed_min
) * RND(1)
'entri brick to the area
t
= INT(2 * RND(1)): posx
= INT((1 + (map_x
- 2) * RND(1)) * t
) + INT(2 * RND(1)) * (map_x
- 1) * ABS(t
= 0)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
'mb array
'0 ena/disa
'1,2 XY location
'3 'direction
'4 stop counter
'5 color index
'6 speed
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 THEN
IF map
(tx
, ty
) = 1 OR map
(tx
, ty
) = 2 THEN IF draw_2d_map
THEN draw_brick_2d tx
, ty
, 1, 0 draw_brick_3d tx, ty, 0, 1
tile_3d tx, ty
'draw mover blocks
IF draw_2d_map
THEN draw_brick_2d mb
(amb
, 1), mb
(amb
, 2), 1, mb
(amb
, 5) 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_2d me
(0), me
(1), me
(5), mb
(0, 0)
'draw money
IF draw_2d_map
THEN draw_brick_2d money
(t
, 0), money
(t
, 1), 1, -1 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))
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
me(3) = me(3) + mousex * mouse_sens '* ABS((_KEYDOWN(19200) OR _KEYDOWN(19712) OR _KEYDOWN(18432) OR _KEYDOWN(20480)) = 0)
me
(4) = me
(4) + mousey
* mouse_sens:
IF ABS(me
(4)) > 80 THEN me
(4) = 80 * SGN(me
(4)) size_block
= size_block
- mw:
IF size_block
< 3 THEN size_block
= 3 ELSE IF size_block
> 140 THEN size_block
= 140
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
OR k_right
OR k_up
OR k_down
) * (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
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)
'money near- 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 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 !"
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)
SUB draw_brick_2d
(x
, y
, relsize
, col
) DIM x
(3), y
(3): xc
= (x
- me
(0)) * size_block
+ .5: yc
= (y
- me
(1)) * size_block
+ .5: rot
= (-me
(3) + 180) * pip180
rotate_2d xc, yc, rot: xc = xc + monx / 2: yc = yc + mony / 2: size = size_block * size_wall * .5 * relsize
FOR t
= 0 TO 3: x
(t
) = size
* -(SGN(t
AND 1) * 2 - 1): y
(t
) = size
* (ABS(t
< 2) * 2 - 1) rotate_2d x
(t
), y
(t
), rot: x
(t
) = INT(x
(t
) + xc
): y
(t
) = INT(y
(t
) + yc
):
NEXT t
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)) IF col
= -1 THEN PAINT ((x
(0) + x
(3)) / 2, (y
(0) + y
(3)) / 2)
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
x = x * 100: y = y * 100: z = z * 100
SUB draw_brick_3d
(x
, y
, text
, relsize
) DIM p
(3, 2), pc
(7, 2), sq
(3) 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", 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))))
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)
draw_square p
(), text_mb
(0, shdw
(ABS(INT((p
(0, 2) + p
(1, 2) + p
(2, 2) + p
(3, 2)) / 4))))
ang
= (TIMER * 2 + _PI * (t
AND 1) + x
+ y
) * (((x
+ y
) AND 1) * 2 - 1) p
(t
, 0) = SIN(ang
) * .5 + x: p
(t
, 2) = COS(ang
) * .5 + y: p
(t
, 1) = SGN(t
AND 2) 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