'---------------------- settings -----------------------------------
room_c = 4 'how many rooms should be in the game?
diamant_c = 10 'average number of diamonds / room
room_doormin = 2 'there must be at least as many doors in a room
room_doormax = 3 'there should be a maximum of this number of doors in a room
me_speed = .15 'my speed
mouse_sens = .5
'-----ADVANCED SETTINGS ----------------------------------------------------------------------------------------------------------------
diamant_speed_min = .05 'diamant speed 1. room
diamant_speed_max = .15 'diamant speed last room
room_buffsize = 100
room_relsize = 20
room_boxmin_c = 4
room_boxmax_c = 6
shdw_c = 40
CONST pip180
= 3.141592 / 180 cheat_active = 0
'make colors
'shadows
'make textures
dia_text_c
= 20:
DIM dia_text
(dia_text_c
- 1, shdw_c
- 1)dt_c = 10
FOR t
= 0 TO shdw_c
- 1: tmax
= 40: tmin
= 40: 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:
FOR tx
= 0 TO size
- 1:
FOR ty
= 0 TO size
- 1: temp_color
(0) = POINT(tx
, ty
)
'make wall
'make door-flash
temp_color
(0) = _RGB32(255, 100, 100): temp_color
(1) = _RGB32(100, 100, 255) 'door 2 colors FOR t2
= 0 TO dt_c
- 1: a
= 1 / (dt_c
- 1) * t2: temp
= _NEWIMAGE(3, 3, 32):
_DEST temp: m
= .5 * dark
cr
= (_RED32(temp_color
(0)) * a
+ _RED32(temp_color
(1)) * (1 - a
)) * m: cg
= (_GREEN32(temp_color
(0)) * a
+ _GREEN32(temp_color
(1)) * (1 - a
)) * m
'make diamants
tmax
= 100: tmin
= 40: size
= INT(tmax
- (tmax
- tmin
) / (shdw_c
- 1) * t
) temp_color
(0) = _RGB32(2 + dark
* 186 * RND(1), 2 + dark
* 186 * RND(1), 2 + dark
* 186 * RND(1)) COLOR temp_color
(0):
CIRCLE (size
/ 2, size
/ 2), size
/ 2 * .95:
PAINT (size
/ 2, size
/ 2), temp_color
(0), temp_color
(0)
'white flash
wf_c
= 20:
DIM wf_text
(wf_c
- 1): sizex
= INT(monx
* .3): sizey
= INT(mony
* .3) PSET (tx
, ty
), _RGBA32(255, 255, 255, ((255 / (sizex
/ 2) * SQR((sizex
/ 2 - tx
) ^ 2 + (sizey
/ 2 - ty
) ^ 2) + 200) * (1 / (wf_c
- 1) * t
)) * .6)
d(0, 1) = -1: d(1, 0) = 1: d(1, 1) = -1: d(2, 0) = 1: d(3, 0) = 1: d(3, 1) = 1
d(4, 1) = 1: d(5, 0) = -1: d(5, 1) = 1: d(6, 0) = -1: d(7, 0) = -1: d(7, 1) = -1
'ROOM array
'0,1,2,3 x1,y1,x2,y2 position in room_map array
'4 number of doors
'20+ ,21+ door coordinates (step5)
'22+ door exit direction
'ROOM_MAP array (room,x,y)
'nothing
'bit 0-walking area
'bit 1,2,3,4-wall
'bit 5 door
DIM SHARED me
(9), cam
(9) '0,1,2 XYZ 3,4 angAB , 5 room
'make rooms
mapsize0
= 20: room
(0, 1) = mapsize0: room
(0, 3) = mapsize0:
FOR tx
= 0 TO mapsize0
- 1:
FOR ty
= 0 TO mapsize0
- 1room_map
(0, tx
, ty
) = 1 + ABS(tx
= 0 OR tx
= mapsize0
- 1 OR ty
= 0 OR ty
= mapsize0
- 1) * 3:
NEXT ty
, tx
room_map
(ar
, INT(room_buffsize
/ 2), INT(room_buffsize
/ 2)) = 1: reg_minmax_reset
0: reg_minmax_reset
1 FOR t
= 0 TO INT(randscale
(room_boxmin_c
, room_boxmax_c
)) - 1 FOR t2
= 0 TO 1: box
(t2
) = INT(randscale
(INT(room_relsize
* (.4 + .2 * t2
)), INT(room_relsize
* (.5 + .2 * t2
)))):
NEXT t2
px2
= INT(box
(0) * RND(1) / 2): py2
= INT(box
(1) * RND(1) / 2):
FOR tx
= 0 TO box
(0) - 1:
FOR ty
= 0 TO box
(1) - 1 wx
= tx
+ px
- px2: wy
= ty
+ py
- py2: room_map
(ar
, wx
, wy
) = 1: reg_minmax
0, wx: reg_minmax
1, wy:
NEXT ty
, tx
, t
room(ar, 0) = rm(0, 0) - 2: room(ar, 1) = rm(0, 1) + 2: room(ar, 2) = rm(1, 0) - 2: room(ar, 3) = rm(1, 1) + 2
'make doors
room
(ar
, 4) = INT(randscale
(room_doormin
, room_doormax
)):
FOR ad
= 0 TO room
(ar
, 4) - 1: agent
= 0 DO: px
= INT((room_buffsize
- 2) * RND(1)) + 1: py
= INT((room_buffsize
- 2) * RND(1)) + 1:
REDIM cnt
(1, 1): dis_nook
= 0 FOR t2
= 0 TO 1:
FOR t
= 0 TO 7 STEP 2 - t2: c
= room_map
(ar
, px
+ d
(t
, 0), py
+ d
(t
, 1)): cnt
(t2
, c
) = cnt
(t2
, c
) + 1:
NEXT t
, t2
FOR ad2
= 0 TO ad: dis_nook
= dis_nook
OR (SQR((room
(ar
, 20 + ad2
* 5) - px
) ^ 2 + (room
(ar
, 21 + ad2
* 5) - py
) ^ 2) < 5 AND (ad2
<> ad
)) agent
= agent
+ 1:
IF agent
> 100000 THEN room
(ar
, 4) = ad
+ 0: agent2
= 1:
GOTO exitroom
room(ar, 20 + ad * 5) = px: room(ar, 21 + ad * 5) = py
FOR t
= 0 TO 7 STEP 2: room
(ar
, 22 + ad
* 5) = room
(ar
, 22 + ad
* 5) OR room_map
(ar
, px
+ d
(t
, 0), py
+ d
(t
, 1)) * t:
NEXT t
, ad
'door exit dir exitroom:
'make wall type
FOR t
= 0 TO 7 STEP 2: room_map
(ar
, tx
, ty
) = room_map
(ar
, tx
, ty
) OR (2 ^ (t
/ 2) * 2) * ABS(room_map
(ar
, tx
+ d
(t
, 0), ty
+ d
(t
, 1)) = 1)
'add door to the room interior
FOR t
= 0 TO add_room_c
- 1: agent
= 0 DO:
FOR t2
= 0 TO 1: box
(t2
) = randscale
(room
(ar
, t2
* 2), room
(ar
, 1 + t2
* 2) - 1):
NEXT t2: room_ok
= 1 FOR tx
= 0 TO 4:
FOR ty
= 0 TO 4:
IF room_map
(ar
, tx
+ box
(0), ty
+ box
(1)) <> 1 THEN room_ok
= 0 FOR t2
= 0 TO 1: room
(ar
, 20 + room
(ar
, 4) * 5 + t2
) = box
(t2
) + 2:
NEXT t2: room
(ar
, 22 + room
(ar
, 4) * 5) = INT(4 * RND(1)) * 2 room_map(ar, box(0) + 2 + d(room(ar, 22 + room(ar, 4) * 5), 0), box(1) + 2 + d(room(ar, 22 + room(ar, 4) * 5), 1)) = 1
room
(ar
, 4) = room
(ar
, 4) + 1:
NEXT t
exitroom2:
'doors to map
FOR ad
= 0 TO room
(ar
, 4) - 1: room_map
(ar
, room
(ar
, 20 + ad
* 5), room
(ar
, 21 + ad
* 5)) = 2 ^ 5:
NEXT ad
'diamants location
dia_c
= diamant_c
* (room_c
- 1):
DIM dia
(dia_c
- 1, 9):
FOR ad
= 0 TO dia_c
- 1: dia
(ad
, 3) = INT((room_c
- 1) * RND(1)) + 1 DO:
FOR t
= 0 TO 1: dia
(ad
, t
) = randscale
(room
(dia
(ad
, 3), t
* 2), room
(dia
(ad
, 3), 1 + t
* 2)):
NEXT t
LOOP UNTIL room_map
(dia
(ad
, 3), dia
(ad
, 0), dia
(ad
, 1)) = 1: dia
(ad
, 2) = .5 dv
= (1 + RND(1)) * (diamant_speed_min
+ (diamant_speed_max
- diamant_speed_min
) / (room_c
- 1) * dia
(ad
, 3)) dega
= 360 * RND(1) * pip180: degb
= 360 * RND(1) * pip180: dia
(ad
, 8) = 1dia
(ad
, 4) = SIN(degb
) * COS(dega
) * dv: dia
(ad
, 5) = SIN(degb
) * SIN(dega
) * dv: dia
(ad
, 6) = COS(degb
) * dv
/ 2:
NEXT ad
'my start position
DO:
FOR t
= 0 TO 1: me
(t
) = randscale
(room
(me
(5), t
* 2), room
(me
(5), 1 + t
* 2)):
NEXT t:
LOOP UNTIL room_map
(me
(5), me
(0), me
(1)) = 1
'allocation of doors
DIM adoor
(room_c
- 1, room_doormax
+ 10, 9) '9-present 0-trans to room 1-trans to door,8 -the only route FOR ar
= 0 TO room_c
- 2 'create only route adoor(ar, door1, 0) = ar + 1: adoor(ar, door1, 1) = door2: adoor(ar, door1, 8) = 1: adoor(ar, door1, 9) = 1
adoor
(ar
+ 1, door2
, 0) = ar: adoor
(ar
+ 1, door2
, 1) = door1: adoor
(ar
+ 1, door2
, 9) = 1:
NEXT ar
adoor
(ar
, ad
, 0) = INT(ar
* RND(1)): adoor
(ar
, ad
, 1) = INT(room
(adoor
(ar
, ad
, 0), 4) * RND(1)): adoor
(ar
, ad
, 9) = 1:
NEXT ad
, ar
PRINT ar;
".room,"; ad;
".door TRANS TO room:"; adoor
(ar
, ad
, 0);
",door:"; adoor
(ar
, ad
, 1):
NEXT ad:
PRINT:
NEXT ar
door_clip_d = 1: crash_active = 1: me(2) = .2 'my height in the game 0-1
'----------------------------------------- BOSS CYCLE -------------------------------------------------------------------------
'cheat keys
boss_limit
= boss_limit
XOR ABS(cheat_active
AND inkey2$
= "l"): crash_active
= crash_active
XOR ABS(cheat_active
AND inkey2$
= "c")
'control me
me
(3) = me
(3) + mousex
* mouse_sens: me
(4) = me
(4) + mousey
* mouse_sens:
IF ABS(me
(4)) > 80 THEN me
(4) = 80 * SGN(me
(4))
try_ang_sc
= 85:
FOR try_ang
= 0 TO try_ang_sc
STEP 6:
FOR try_ang_dir
= 0 TO 1 go
= me_speed
* ABS((k_left
+ k_right
+ k_up
+ k_down
) = -1) * (1 / try_ang_sc
* (try_ang_sc
- try_ang
)) go_ang = k_down * 180 + 90 * (k_left - k_right) + (me(3) + (try_ang_dir * 2 - 1) * try_ang): kit = .2
go_xa
= SIN(go_ang
* pip180
) * kit
+ me
(0): go_ya
= -COS(go_ang
* pip180
) * kit
+ me
(1): go_xg
= SIN(go_ang
* pip180
) * go
+ me
(0) go_yg
= -COS(go_ang
* pip180
) * go
+ me
(1):
IF crash
(go_xa
, go_ya
) = 0 THEN me
(0) = go_xg: me
(1) = go_yg:
GOTO ok
NEXT try_ang_dir
, try_ang
ok:
FOR t
= 0 TO 9: cam
(t
) = me
(t
):
NEXT t: door_clip
= door_clip
+ door_clip_d:
IF INT(door_clip
) < 1 OR INT(door_clip
) > dt_c
- 2 THEN door_clip_d
= -door_clip_d
'draw objects
FOR tx
= 0 TO room
(me
(5), 1) - room
(me
(5), 0):
FOR ty
= 0 TO room
(me
(5), 3) - room
(me
(5), 2) l = room_map(me(5), room(me(5), 0) + tx, room(me(5), 2) + ty)
roof
= (1 - ABS(me
(5) = 0)) FOR t2
= 0 TO roof:
FOR t
= 0 TO 3: p
(t
, 0) = tx
+ (SGN(t
AND 1) * 2 - 1) * .5: p
(t
, 2) = ty
+ (SGN(t
AND 2) * 2 - 1) * .5: p
(t
, 1) = t2
point_3d p
(t
, 0), p
(t
, 1), p
(t
, 2):
NEXT t: draw_square p
(), text_tile
(me
(5), shdw
(ABS(INT((p
(0, 2) + p
(1, 2) + p
(2, 2) + p
(3, 2)) / 4)))) IF l
/ 2 AND 15 THEN draw_brick_3d tx
, ty
'WALL dt
= 0:
FOR t2
= 0 TO 7 STEP 2: dt
= dt
OR (t2
* ABS(room_map
(me
(5), room
(me
(5), 0) + tx
+ d
(t2
, 0), room
(me
(5), 2) + ty
+ d
(t2
, 1)) = 1)) NEXT t2:
FOR t
= 0 TO 3: p
(t
, 0) = (SGN(t
AND 1) * 2 - 1) * .5: p
(t
, 2) = 0: p
(t
, 1) = (SGN(t
AND 2) * 2 - 1) * .5 + .5 rotate_2d p
(t
, 0), p
(t
, 2), 90 * pip180
* SGN(dt
AND 2) p(t, 0) = p(t, 0) + tx: p(t, 2) = p(t, 2) + ty: point_3d p(t, 0), p(t, 1), p(t, 2)
NEXT t: draw_square p
(), door_text
(INT(door_clip
), shdw
(ABS(INT((p
(0, 2) + p
(1, 2) + p
(2, 2) + p
(3, 2)) / 4))))
'white flash
w_dis
= .7: mindis
= 999999:
FOR ad
= 0 TO room
(me
(5), 4) - 1 dis
= SQR((me
(0) - room
(me
(5), 20 + 5 * ad
)) ^ 2 + (me
(1) - room
(me
(5), 21 + 5 * ad
)) ^ 2):
IF dis
< mindis
THEN mindis
= dis: trans_door
= ad
'near door / trans to another room
IF mindis
< .5 AND adoor
(me
(5), trans_door
, 9) THEN ndoor = adoor(me(5), trans_door, 1): me(5) = adoor(me(5), trans_door, 0)
FOR t
= 0 TO 1: q
(t
) = d
(room
(me
(5), 22 + ndoor
* 5), t
): me
(t
) = room
(me
(5), 20 + t
+ ndoor
* 5) + q
(t
):
NEXT t
me(3) = -degree(q(0), q(1)) + 180: awf = wf_c - 1
'draw diamants
'DIAMANT array
'0,1,2 XYZ-location
'3,room-location
'4,5,6 XYZ vector
'8 active status 1-active
diar = 10
'catch
catch
= ABS((k_left
+ k_right
+ k_up
+ k_down
) = -1) AND SQR((dia
(ad
, 0) - me
(0)) ^ 2 + (dia
(ad
, 1) - me
(1)) ^ 2) < .5
'diamants move
newpos
= dia
(ad
, 2) + dia
(ad
, 6):
IF newpos
< 0 OR newpos
> 1 THEN dia
(ad
, 6) = -dia
(ad
, 6) newpos
= dia
(ad
, 0) + dia
(ad
, 4):
IF room_map
(me
(5), newpos
, dia
(ad
, 1)) <> 1 THEN dia
(ad
, 4) = -dia
(ad
, 4) newpos
= dia
(ad
, 1) + dia
(ad
, 5):
IF room_map
(me
(5), dia
(ad
, 0), newpos
) <> 1 THEN dia
(ad
, 5) = -dia
(ad
, 5) FOR t
= 0 TO 2: dia
(ad
, t
) = dia
(ad
, t
) + dia
(ad
, 4 + t
):
NEXT t
'diamants draw
x = dia(ad, 0) - room(me(5), 0): z = dia(ad, 1) - room(me(5), 2): y = dia(ad, 2): point_3d x, y, z
FOR t
= 0 TO 3: p
(t
, 0) = (SGN(t
AND 1) * 2 - 1) * diar
+ x: p
(t
, 2) = z: p
(t
, 1) = (SGN(t
AND 2) * 2 - 1) * diar
+ y:
NEXT t
draw_square p
(), dia_text
(INT(dia_text_c
* RND(1)), shdw
(ABS(INT((p
(0, 2) + p
(1, 2) + p
(2, 2) + p
(3, 2)) / 4))))
'stroryline
REDIM sum
(room_c
- 1): my_dia
= 0:
FOR ad
= 0 TO dia_c
- 1: my_dia
= my_dia
+ dia
(ad
, 8): sum
(dia
(ad
, 3)) = sum
(dia
(ad
, 3)) + dia
(ad
, 8):
NEXT ad
mess$ = "Get all diamant !"
IF me
(5) = 0 THEN mess$
= "CONGRATULATION !" ELSE mess$
= "Go back to the START-ROOM !"
SUB reg_minmax_reset
(n
): rm
(n
, 0) = 9999999: rm
(n
, 1) = -rm
(n
, 0):
END SUB SUB reg_minmax
(n
, a
):
IF a
< rm
(n
, 0) THEN rm
(n
, 0) = a
ELSE IF a
> rm
(n
, 1) THEN rm
(n
, 1) = a
FUNCTION degree
(a
, b
): degreex
= ATN(a
/ (b
+ .00001)) / pip180: degreex
= degreex
- 180 * ABS(0 > b
): degreex
= degreex
- 360 * (degreex
< 0): degree
= degreex:
END FUNCTION 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
SUB point_3d
(x
, y
, z
): x
= (x
- cam
(0) + room
(cam
(5), 0)) * 100: y
= (y
- cam
(2)) * 100: z
= (z
- cam
(1) + room
(cam
(5), 2)) * 100 rotate_2d x
, z
, -(cam
(3) + 180) * pip180: rotate_2d y
, z
, (cam
(4) + 180) * pip180:
END SUB
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
REDIM pc
(7, 2):
FOR t
= 0 TO 7: pc
(t
, 0) = .5 * (SGN(t
AND 1) * 2 - 1) + x: pc
(t
, 2) = .5 * (SGN(t
AND 2) * 2 - 1) + y: pc
(t
, 1) = .5 * SGN(t
AND 4) * 2 point_3d pc
(t
, 0), pc
(t
, 1), pc
(t
, 2):
NEXT t:
FOR t
= 0 TO 4:
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_tile
(me
(5), shdw
(ABS(INT((p
(0, 2) + p
(1, 2) + p
(2, 2) + p
(3, 2)) / 4))))