CONST pip180
= 3.141592 / 180 CONST perlin_pers
= 7 'amplitudo CONST perlin_level
= 5 'level of resolution wave 'CONST perlin_multiplier = 0.006
CONST perlin_multiplier
= 0.008 CONST perlin_smooth_noise_interpolation_type
= 0 '0-none '1-standard CONST perlin_flat_soil_limit_low
= .8 'high value is low area (negate) CONST perlin_flat_soil_limit_high
= .1 CONST flight_array_size
= 20:
DIM flight_save
(flight_array_size
- 1) DIM SHARED rotating
(2), cosrotz
, sinrotz
, cosrotx
, sinrotx
, map_zoom_xy
, map_zoom_distance
, see_point
, flight
(19, flight_array_size
), me
(19), rotx_bevel
DIM SHARED mouse_sens_xy
, mouse_sens_z
, position_speed
, clmn_rad
DIM SHARED map_x
, map_y
, perl_setx
, perl_sety
, map_resolution
, map_z
, map_dimz
, map_dimxy
, flight_high_max
monx = 1366: mony = monx / 16 * 9 'screen size
win_marg = monx / 25
flight_high_max = -70
text_deep = 30 'make deep shadow pictures
map_center = 100000 'start of perlin-map
text_field$ = "need\field2.bmp"
text_field$ = "need\field1.bmp" 'field map texture
text_multi = 40 'zoom to texture
position_speed = .9
map_resolution = 60 'see map resolution
DIM SHARED map_resper2: map_resper2
= INT(map_resolution
/ 2)
DIM SHARED max_incli: max_incli
= 65 'flight max rotation
map_dimxy = 1200 * .8
map_dimz = 250 * .8
map_zoom_xy = 6 * .2
map_zoom_distance = 15 * .2
mouse_sens_xy = 1.6
mouse_sens_z = 1
me(6) = pip180 * 270
me(0) = map_center: me(1) = map_center
control_type$(0) = "walking": control_type$(1) = "flying": control_type$(2) = "flying/autopilot"
DIM clmn
(1999, 5): clmn_rad
= 30: ration_column
= 0.0003: ration_column
= 0.002
'install radar
rad_ts = 600: rad_size = monx / 5.5: r1 = rad_ts / 2 * .96: r2 = rad_ts / 2 * .80
CIRCLE (rad_ts
/ 2, rad_ts
/ 2), r1
, color_temp
(0):
CIRCLE (rad_ts
/ 2, rad_ts
/ 2), r2
, color_temp
(0) PAINT (rad_ts
/ 2 + (r1
+ r2
) / 2, rad_ts
/ 2), color_temp
(0), color_temp
(0):
PAINT (rad_ts
/ 2, rad_ts
/ 2), _RGBA(100, 100, 255, 150), color_temp
(0)
'radar object
CIRCLE (rado_ts
/ 2, rado_ts
/ 2), rado_ts
/ 2 * .98, color_temp
(0)
'make sky
da
= 8: db
= 8: sky_points
= da
* db:
DIM sky_points
(sky_points
- 1, 9), sq
(sky_points
- 1, 7): sky_image
= _LOADIMAGE("need\sky.jpg", 33)FOR da2
= 0 TO da
- 1: dega
= 360 / (da
- 1) * da2
* pip180:
FOR db2
= 0 TO db
- 1: degb
= 180 / (db
- 1) * db2
* pip180: ss
= 1400 ap
= da2
* db
+ db2: sky_points
(ap
, 0) = SIN(degb
) * COS(dega
) * ss: sky_points
(ap
, 1) = SIN(degb
) * SIN(dega
) * ss: sky_points
(ap
, 2) = COS(degb
) * ss:
NEXT db2
, da2
FOR da2
= 0 TO da
- 2:
FOR db2
= 0 TO db
- 2: sqa
= da2
* db
+ db2: sq
(sqa
, 0) = sqa: sq
(sqa
, 1) = sq
(sqa
, 0) + 1: sq
(sqa
, 2) = sq
(sqa
, 0) + db: sq
(sqa
, 3) = sq
(sqa
, 2) + 1 sq
(sqa
, 4) = _WIDTH(sky_image
) - (_WIDTH(sky_image
) / (da
- 1) * da2
) - 1: sq
(sqa
, 5) = _WIDTH(sky_image
) - (_WIDTH(sky_image
) / (da
- 1) * (da2
+ 1)) - 1sq
(sqa
, 6) = INT(_HEIGHT(sky_image
) / (db
- 1) * db2
): sq
(sqa
, 7) = INT(_HEIGHT(sky_image
) / (db
- 1) * (db2
+ 1)):
NEXT db2
, da2
'create pseudo random buffer
'create texture
FOR t
= 0 TO text_deep
- 1: dark
= (1 - (1 / (text_deep
- 1) * t
)): transp
= dark
* 2000:
IF transp
> 255 THEN transp
= 255 c1
= _RED32(temp_color
(0)) * dark: c2
= _GREEN32(temp_color
(0)) * dark: c3
= _BLUE32(temp_color
(0)) * dark
'find min/max Z
DIM SHARED mapz_multiplier: mapz_min
= 9999999: mapz_max
= -mapz_min:
FOR t
= 0 TO 2999: c
= Perlin2D_original
(5000 * RND(1), 5000 * RND(1)) mapz_min
= c
* ABS(mapz_min
> c
) + mapz_min
* (ABS(mapz_min
> c
) XOR 1): mapz_max
= c
* ABS(mapz_max
< c
) + mapz_max
* (ABS(mapz_max
< c
) XOR 1)NEXT t: mapz_multiplier
= 1 / (mapz_max
- mapz_min
)
'fill map-buffer
DIM SHARED map
(map_resolution
- 1, map_resolution
- 1, 19): perl_setx
= INT(me
(0)): perl_sety
= INT(me
(1)) FOR map_x
= 0 TO map_resolution
- 1:
FOR map_y
= 0 TO map_resolution
- 1 map
((map_x
+ perl_setx
) MOD map_resolution
, (map_y
+ perl_sety
) MOD map_resolution
, 0) = perlin2d
(perl_setx
+ map_x
, perl_sety
+ map_y
)map
((map_x
+ perl_setx
) MOD map_resolution
, (map_y
+ perl_sety
) MOD map_resolution
, 6) = noise
(map_x
, map_y
) < ration_column:
NEXT map_y
, map_x
'calculating shadows
FOR map_x
= 0 TO map_resolution
- 1:
FOR map_y
= 0 TO map_resolution
- 1 dis
= INT((text_deep
- 1) / map_resper2
* SQR((map_x
- map_resper2
) ^ 2 + (map_y
- map_resper2
) ^ 2)):
IF dis
< 0 OR dis
> text_deep
- 1 THEN _CONTINUEmap
(map_x
, map_y
, 9) = 1: map
(map_x
, map_y
, 8) = dis:
NEXT map_y
, map_x
'MAP array
'0-perlin Z-data
'1-maptriangle calculate X
'2-maptriangle calculate Y
'3-maptriangle calculate Z
'4-distance from me (color)
'5-texture height scale
'6-is there a column ?
'7-is the point visible?
'8-shadow-table
'9-not used area signal
'ME array
'0-me X location
'1-me Y location
'2-me Z location
'3-vector_x
'4-vector_y
'5-me XY angle CAM3
'6-me XY CAM4
'7-me kanyarodas merteke
'FLIGHT array
'0-active
'1-rotx - kanyarodas merteke
'2-rotx_bevel
'3-location X
'4-location Y
'5-location Z
'6-vector X
'7-vector Y
'8-W gas
'9-S brake
'10-mouseX
'11-mouseZ
'12 cam4 /me6
'13 cam3 /me5
'15 actual speed
'16 column (XY) crash /last step
'17 land (Z) crash /last step
auto_precalc = 28
auto_mouse_scale = 140
auto_try_resolution = 22
DIM flight_auto
(auto_try_resolution
- 1, flight_array_size
- 1) DIM auto_efficiency
(auto_try_resolution
- 1, 5) '0- 1 if crash '1- target-flight distance
control_type = 0
_PRINTSTRING (0, 0), "moving:mouse+WASD jump:space walking/fly: F"
IF ut_kf
= 0 AND kf
THEN control_type
= (control_type
+ 1) MOD 3 ut_kf = kf
walk_speed = .18
_PRINTSTRING (500, 0), "control type : " + control_type$
(control_type
) + " "
me(3) = 0: me(4) = 0: me(7) = 0: flight(0, 1) = 0
me(5) = me(5) + mousex * mouse_sens_xy / 200: me(6) = me(6) + mousey * mouse_sens_xy / 200
go
= ABS(ka
OR kd
OR kw
OR ks
): direction
= (-90 * ABS(ka
) + 90 * ABS(kd
) + 180 * ABS(ks
)) * go
* pip180
go_x
= -(SIN(direction
+ me
(5)) * walk_speed
) * go: go_y
= -(COS(direction
+ me
(5)) * walk_speed
) * go
IF crash_to_column
(me
(0) + go_x
, me
(1) + go_y
) THEN go_x
= 0: go_y
= 0
me(0) = me(0) + go_x: me(1) = me(1) + go_y
IF (map_deep
(me
(0), me
(1)) - .18) * map_dimz
> me
(2) THEN walk_c_down = walk_c_down + .2: me(2) = me(2) + walk_c_down: free_jump = 0
ELSE walk_c_down
= 0: me
(2) = (map_deep
(me
(0), me
(1)) - .18) * map_dimz: free_jump
= 1
rotx_bevel
= rotx_bevel
* .95: me
(2) = me
(2) - jump_cf
/ 4: jump_cf
= jump_cf
- 1:
IF jump_cf
< 0 THEN jump_cf
= 0
'contact between me and flight0
flight
(0, 2) = rotx_bevel: flight
(0, 8) = ABS(kw
): flight
(0, 9) = ABS(ks
): flight
(0, 10) = mousex
* mouse_sens_xy: flight
(0, 11) = mousey
* mouse_sens_z
flight(0, 3) = me(0): flight(0, 4) = me(1): flight(0, 5) = me(2): flight(0, 6) = me(3): flight(0, 7) = me(4): flight(0, 12) = me(6): flight(0, 13) = me(5)
flight_control 0, 0
me(0) = flight(0, 3): me(1) = flight(0, 4): me(2) = flight(0, 5): me(3) = flight(0, 6): me(4) = flight(0, 7): me(5) = flight(0, 13): me(6) = flight(0, 12)
rotx_bevel = flight(0, 2)
flight
(0, 2) = rotx_bevel: flight
(0, 8) = ABS(kw
): flight
(0, 9) = ABS(ks
): flight
(0, 10) = mousex
* mouse_sens_xy: flight
(0, 11) = mousey
* mouse_sens_z
flight(0, 3) = me(0): flight(0, 4) = me(1): flight(0, 5) = me(2): flight(0, 6) = me(3): flight(0, 7) = me(4): flight(0, 12) = me(6): flight(0, 13) = me(5)
FOR t
= 0 TO flight_array_size
- 1: flight_save
(t
) = flight
(0, t
):
NEXT t
'calculation of options
FOR a_try
= 0 TO auto_try_resolution
- 1: auto_efficiency
(a_try
, 0) = 0 FOR t
= 0 TO flight_array_size
- 1: flight
(0, t
) = flight_save
(t
):
NEXT t
flight(0, 8) = 1: flight(0, 10) = -auto_mouse_scale + (auto_mouse_scale * 2) / (auto_try_resolution - 1) * a_try
auto_efficiency
(a_try
, 1) = ABS((targ
(0) - flight
(0, 3)) ^ 2 + (targ
(1) - flight
(0, 4)) ^ 2):
NEXT a_try
'choosing the most effective option
adis
= 999999: auto_opt
= -1:
FOR t
= 0 TO auto_try_resolution
- 1 IF auto_efficiency
(t
, 0) = 0 AND auto_efficiency
(t
, 1) < adis
THEN adis
= auto_efficiency
(t
, 1): auto_opt
= t
NEXT t:
IF auto_opt
= -1 THEN auto_opt
= INT(auto_try_resolution
* RND(1)): auto_rand
= auto_rand
+ 1
FOR t
= 0 TO flight_array_size
- 1: flight
(0, t
) = flight_save
(t
):
NEXT t
flight(0, 8) = 1: flight(0, 10) = -auto_mouse_scale + (auto_mouse_scale * 2) / (auto_try_resolution - 1) * auto_opt: flight_control 0, 0
me(0) = flight(0, 3): me(1) = flight(0, 4): me(2) = flight(0, 5): me(3) = flight(0, 6): me(4) = flight(0, 7): me(5) = flight(0, 13): me(6) = flight(0, 12)
rotx_bevel = flight(0, 2)
'replace the missing row in the buffer line Y
DO WHILE INT(INT(me
(0))) <> perl_setx: dir
= -SGN(INT(me
(0)) - perl_setx
): perl_setx
= perl_setx
- dir
temp
= INT(perl_setx
+ ABS(dir
= -1) * (map_resolution
- 1)): temp_m
= INT(temp
MOD map_resolution
) FOR map_y
= 0 TO map_resolution
- 1: map
(temp_m
, INT(map_y
+ perl_sety
) MOD map_resolution
, 0) = perlin2d
(temp
, perl_sety
+ map_y
) map
(temp_m
, INT((map_y
+ perl_sety
) MOD map_resolution
), 6) = noise
(temp
, perl_sety
+ map_y
) < ration_column:
NEXT map_y:
LOOP
'replace the missing row in the buffer line X
DO WHILE INT(INT(me
(1))) <> perl_sety: dir
= -SGN(INT(me
(1)) - perl_sety
): perl_sety
= perl_sety
- dir
temp
= perl_sety
+ ABS(dir
= -1) * (map_resolution
- 1): temp_m
= INT(temp
MOD map_resolution
) FOR map_x
= 0 TO map_resolution
- 1: map
(INT((map_x
+ perl_setx
) MOD map_resolution
), temp_m
, 0) = perlin2d
(perl_setx
+ map_x
, temp
) map
(INT(map_x
+ perl_setx
) MOD map_resolution
, temp_m
, 6) = noise
(perl_setx
+ map_x
, temp
) < ration_column:
NEXT map_x:
LOOP
cosrotz
= COS(me
(5)): sinrotz
= SIN(me
(5)): cosrotx
= COS(me
(6)): sinrotx
= SIN(me
(6)) 'to rotating angles
'draw sky
FOR actual_point
= 0 TO sky_points
- 1: rotate sky_points
(actual_point
, 0), sky_points
(actual_point
, 1), sky_points
(actual_point
, 2), 0 sky_points
(actual_point
, 4) = rotating
(0): sky_points
(actual_point
, 5) = rotating
(1): sky_points
(actual_point
, 6) = rotating
(2):
NEXT actual_point
FOR asq
= 0 TO sky_points
- 1 wx0 = sky_points(sq(asq, 0), 4): wy0 = sky_points(sq(asq, 0), 5): wz0 = sky_points(sq(asq, 0), 6)
wx1 = sky_points(sq(asq, 1), 4): wy1 = sky_points(sq(asq, 1), 5): wz1 = sky_points(sq(asq, 1), 6)
wx2 = sky_points(sq(asq, 2), 4): wy2 = sky_points(sq(asq, 2), 5): wz2 = sky_points(sq(asq, 2), 6)
wx3 = sky_points(sq(asq, 3), 4): wy3 = sky_points(sq(asq, 3), 5): wz3 = sky_points(sq(asq, 3), 6)
sy0 = sq(asq, 6): sx0 = sq(asq, 4): sy1 = sq(asq, 7): sx1 = sq(asq, 4): sy2 = sq(asq, 6): sx2 = sq(asq, 5): sy3 = sq(asq, 7): sx3 = sq(asq, 5)
_MAPTRIANGLE (sx0
, sy0
)-(sx1
, sy1
)-(sx2
, sy2
), sky_image
TO(wx0
, wy0
, wz0
)-(wx1
, wy1
, wz1
)-(wx2
, wy2
, wz2
), , _SMOOTH _MAPTRIANGLE (sx3
, sy3
)-(sx1
, sy1
)-(sx2
, sy2
), sky_image
TO(wx3
, wy3
, wz3
)-(wx1
, wy1
, wz1
)-(wx2
, wy2
, wz2
), , _SMOOTH
'calculating position and textures
clmn(0, 0) = 0 'reset column counter
FOR map_x
= 0 TO map_resolution
- 1: px
= -map_dimxy
/ 2 + map_dimxy
/ map_resolution
* (map_x
- (me
(0) - INT(me
(0)))) py
= -map_dimxy
/ 2 + map_dimxy
/ map_resolution
* (map_y
- (me
(1) - INT(me
(1)))) read_mapx
= INT((map_x
+ perl_setx
) MOD map_resolution
): read_mapy
= INT((map_y
+ perl_sety
) MOD map_resolution
): map_z
= map
(read_mapx
, read_mapy
, 0) map
(map_x
, map_y
, 7) = 0: pz2
= map_dimz
* map_z
- me
(2): rotate px
, py
, pz2
, 1:
IF see_point
= 0 THEN _CONTINUE map(map_x, map_y, 1) = rotating(0): map(map_x, map_y, 2) = rotating(1): map(map_x, map_y, 3) = rotating(2): map(map_x, map_y, 7) = 1
map
(map_x
, map_y
, 5) = INT(text_height_scale
* map_z
):
IF map
(map_x
, map_y
, 5) > text_height_scale
- 1 THEN map
(map_x
, map_y
, 5) = text_height_scale
- 1 IF map
(map_x
, map_y
, 5) < 0 THEN map
(map_x
, map_y
, 5) = 0 IF map
(read_mapx
, read_mapy
, 6) THEN clmn
(clmn
(0, 0) + 1, 2) = map
(map_x
, map_y
, 8): clmn
(clmn
(0, 0) + 1, 0) = px: clmn
(clmn
(0, 0) + 1, 1) = py: clmn
(0, 0) = clmn
(0, 0) + 1
'do maptriangle from squares !
FOR map_x
= 0 TO map_resolution
- 2:
FOR map_y
= 0 TO map_resolution
- 2 IF (map
(map_x
, map_y
, 7) AND map
(map_x
+ 1, map_y
, 7) AND map
(map_x
, map_y
+ 1, 7) AND map
(map_x
+ 1, map_y
+ 1, 7)) = 0 THEN _CONTINUE m0x = map(map_x, map_y, 1): m0y = map(map_x, map_y, 2): m0z = map(map_x, map_y, 3)
m1x = map(map_x + 1, map_y, 1): m1y = map(map_x + 1, map_y, 2): m1z = map(map_x + 1, map_y, 3)
m2x = map(map_x, map_y + 1, 1): m2y = map(map_x, map_y + 1, 2): m2z = map(map_x, map_y + 1, 3)
m3x = map(map_x + 1, map_y + 1, 1): m3y = map(map_x + 1, map_y + 1, 2): m3z = map(map_x + 1, map_y + 1, 3)
atexture = texture(map(map_x, map_y, 8), 0)
sx1 = (perl_setx + map_x) * text_multi: sy1 = (perl_sety + map_y) * text_multi: sx2 = sx1 + text_multi: sy2 = sy1 + text_multi
_MAPTRIANGLE (sx1
, sy1
)-(sx2
, sy1
)-(sx1
, sy2
), atexture
TO(m0x
, m0y
, m0z
)-(m1x
, m1y
, m1z
)-(m2x
, m2y
, m2z
) _MAPTRIANGLE (sx2
, sy2
)-(sx2
, sy1
)-(sx1
, sy2
), atexture
TO(m3x
, m3y
, m3z
)-(m1x
, m1y
, m1z
)-(m2x
, m2y
, m2z
)
'draw columns
ac_ang
= 11: column_height
= 800: column_rot
= column_rot
+ 1:
FOR ac
= 0 TO clmn
(0, 0) - 1:
FOR t
= 0 TO ac_ang
- 1 temp
= (360 / ac_ang
* t
+ column_rot
) * pip180: px
= clmn
(ac
+ 1, 0) + SIN(temp
) * clmn_rad: py
= clmn
(ac
+ 1, 1) + COS(temp
) * clmn_rad
pz2 = 300 - me(2): rotate px, py, pz2, 0: ac(t, 0, 0) = rotating(0): ac(t, 1, 0) = rotating(1): ac(t, 2, 0) = rotating(2)
pz2
= -150 - me
(2): rotate px
, py
, pz2
, 0: ac
(t
, 0, 1) = rotating
(0): ac
(t
, 1, 1) = rotating
(1): ac
(t
, 2, 1) = rotating
(2):
NEXT t
FOR t
= 0 TO ac_ang
- 1: t2
= (t
+ 1) MOD ac_ang
m0x = ac(t, 0, 0): m0y = ac(t, 1, 0): m0z = ac(t, 2, 0): m1x = ac(t2, 0, 0): m1y = ac(t2, 1, 0): m1z = ac(t2, 2, 0)
m2x = ac(t, 0, 1): m2y = ac(t, 1, 1): m2z = ac(t, 2, 1): m3x = ac(t2, 0, 1): m3y = ac(t2, 1, 1): m3z = ac(t2, 2, 1)
atexture = texture(clmn(ac + 1, 2), 0): dd = 4: pm = 40 * dd: pm2 = 310 * dd: sx1 = pm * t: sy1 = pm2: sx2 = sx1 + pm: sy2 = sy1 + pm2
_MAPTRIANGLE (sx1
, sy1
)-(sx2
, sy1
)-(sx1
, sy2
), atexture
TO(m0x
, m0y
, m0z
)-(m1x
, m1y
, m1z
)-(m2x
, m2y
, m2z
) _MAPTRIANGLE (sx2
, sy2
)-(sx2
, sy1
)-(sx1
, sy2
), atexture
TO(m3x
, m3y
, m3z
)-(m1x
, m1y
, m1z
)-(m2x
, m2y
, m2z
)
'target draw
dis
= SQR((targ
(0) - me
(0)) ^ 2 + (targ
(1) - me
(1)) ^ 2):
_PRINTSTRING (0, 20), "target distance:" + STR$(dis
)
IF dis
< map_resolution
/ 2 * 1.5 THEN ee = map_dimxy / map_resolution: targ_size = 50: rotate (targ(0) - me(0)) * ee, (targ(1) - me(1)) * ee, (targ(2) - me(2)) * 1, 0
m0x = rotating(0) - targ_size: m0y = rotating(1) - targ_size: m0z = rotating(2): m1x = rotating(0) + targ_size: m1y = rotating(1) - targ_size: m1z = rotating(2)
m2x = rotating(0) - targ_size: m2y = rotating(1) + targ_size: m2z = rotating(2): m3x = rotating(0) + targ_size: m3y = rotating(1) + targ_size: m3z = rotating(2)
_MAPTRIANGLE (0, 500 - 1)-(500 - 1, 500 - 1)-(0, 0), targ_text
TO(m0x
, m0y
, m0z
)-(m1x
, m1y
, m1z
)-(m2x
, m2y
, m2z
) _MAPTRIANGLE (500 - 1, 0)-(500 - 1, 500 - 1)-(0, 0), targ_text
TO(m3x
, m3y
, m3z
)-(m1x
, m1y
, m1z
)-(m2x
, m2y
, m2z
)
new_target_signal
= new_target_signal
- 1:
IF new_target_signal
< 0 THEN new_target_signal
= 0
'draw radar
m0x = win_marg: m1x = m0x + rad_size: m0y = mony - rad_size - win_marg: m1y = m0y + rad_size
_MAPTRIANGLE (0, 0)-(rad_ts
- 1, 0)-(0, rad_ts
- 1), rad_text
TO(m0x
, m0y
)-(m1x
, m0y
)-(m0x
, m1y
), , _SMOOTH _MAPTRIANGLE (rad_ts
- 1, rad_ts
- 1)-(rad_ts
- 1, 0)-(0, rad_ts
- 1), rad_text
TO(m1x
, m1y
)-(m1x
, m0y
)-(m0x
, m1y
), , _SMOOTH
'draw objects in radar
rad_obj_multi = .8: rad_obj_limit = rad_size / 2 * .9: angle = me(5) + (degree(targ(1) - me(1), targ(0) - me(0)) - 90) * pip180
dis
= SQR((targ
(0) - me
(0)) ^ 2 + (targ
(1) - me
(1)) ^ 2) * rad_obj_multi:
IF dis
> rad_obj_limit
THEN dis
= rad_obj_limit
x
= SIN(angle
) * dis
+ win_marg
+ rad_size
/ 2: y
= mony
- win_marg
- rad_size
/ 2 + COS(angle
) * dis: ros
= 10 _MAPTRIANGLE (0, 0)-(rado_ts
- 1, 0)-(0, rado_ts
- 1), rado_text
TO(x
- ros
, y
- ros
)-(x
+ ros
, y
- ros
)-(x
- ros
, y
+ ros
), , _SMOOTH _MAPTRIANGLE (rado_ts
- 1, rado_ts
- 1)-(rado_ts
- 1, 0)-(0, rado_ts
- 1), rado_text
TO(x
+ ros
, y
+ ros
)-(x
+ ros
, y
- ros
)-(x
- ros
, y
+ ros
), , _SMOOTH
new_target: l
= 200: targ
(0) = map_center
+ l
/ 2 + l
* RND(1): targ
(1) = map_center
+ l
/ 2 + l
* RND(1): targ
(2) = (map_deep
(targ
(0), targ
(1)) - .1 - targ_size
/ 2)new_target_signal
= 160:
RETURN
FUNCTION noise
(x
, y
) 'reading pseudo random buffer x2
= INT(x
): y2
= INT(y
): a
= INT(ABS(x2
) + ABS(y2
)) MOD noise_rand_c: b
= ABS(x2
) MOD noise_rand_c: c
= noise_rand
(a
) + noise_rand
(b
): noise
= c
- INT(c
)
SELECT CASE perlin_smooth_noise_interpolation_type
CASE 0: SmoothNoise
= noise
(x
, y
) CASE 1: corners
= (noise
(x
- 1, y
- 1) + noise
(x
+ 1, y
- 1) + noise
(x
- 1, y
+ 1) + noise
(x
+ 1, y
+ 1)) / 16 sides = (noise(x - 1, y) + noise(x + 1, y) + noise(x, y - 1) + noise(x, y + 1)) / 8: center = noise(x, y) / 4: SmoothNoise = corners + sides + center
FUNCTION Perlin2D_original
(x
, y
): total
= 0:
FOR t
= 0 TO perlin_level
- 1: frequency
= 2 ^ t
* perlin_multiplier: amplitude
= perlin_pers
^ t
total
= total
+ InterpolatedNoise
(x
* frequency
, y
* frequency
) * amplitude:
NEXT t: Perlin2D_original
= total:
END FUNCTION
FUNCTION perlin2d
(x
, y
): perlin2dx
= mapz_multiplier
* (Perlin2D_original
(x
, y
) - mapz_min
) IF perlin2dx
> perlin_flat_soil_limit_low
THEN perlin2dx
= perlin_flat_soil_limit_low
IF perlin2dx
< perlin_flat_soil_limit_high
THEN perlin2dx
= perlin_flat_soil_limit_high
perlin2d = perlin2dx
FUNCTION InterpolatedNoise
(x
, y
): integer_X
= INT(x
): fractional_X
= x
- integer_X: integer_y
= INT(y
): fractional_Y
= y
- integer_y
v1 = SmoothNoise(integer_X, integer_y): v2 = SmoothNoise(integer_X + 1, integer_y)
v3 = SmoothNoise(integer_X, integer_y + 1): v4 = SmoothNoise(integer_X + 1, integer_y + 1)
i1
= Interpolate
(v1
, v2
, fractional_X
): i2
= Interpolate
(v3
, v4
, fractional_X
): InterpolatedNoise
= Interpolate
(i1
, i2
, fractional_Y
):
END FUNCTION
SUB rotate
(px
, py
, pz2
, see_analysis
) px3 = px * cosrotz - py * sinrotz: py2 = px * sinrotz + py * cosrotz: py3 = py2 * cosrotx - pz2 * sinrotx: pz3 = -(py2 * sinrotx + pz2 * cosrotx)
rotating
(0) = -(px3
* COS(rotx_bevel
) - py3
* SIN(rotx_bevel
)) * map_zoom_xy: rotating
(1) = -(px3
* SIN(rotx_bevel
) + py3
* COS(rotx_bevel
)) * map_zoom_xy
rotating
(2) = pz3
* map_zoom_distance:
END SUB
SUB flight_control
(af
, test
)
rotx
= flight
(af
, 1): me0
= flight
(af
, 3): me1
= flight
(af
, 4): me2
= flight
(af
, 5): me3
= flight
(af
, 6): me4
= flight
(af
, 7): kw
= ABS(flight
(af
, 8)) ks
= ABS(flight
(af
, 9)): mousey
= flight
(af
, 11): mousex
= flight
(af
, 10): me6
= flight
(af
, 12): me5
= flight
(af
, 13): rotx_bevel3
= flight
(af
, 2)
rotx
= (rotx
+ mousex
* .005) * .95:
IF ABS(rotx
) > (max_incli
* pip180
) THEN rotx
= max_incli
* pip180
* SGN(rotx
)
actual_speed
= 1 / position_speed
* SQR(me3
* me3
+ me4
* me4
): rotx_bevel2
= rotx
* actual_speed
* kw
rotx_bevel3 = rotx_bevel3 + (rotx_bevel2 - rotx_bevel3) * .05: me5 = me5 + rotx / 20: me6 = me6 + mousey / 100: lim_fy = 65: temp = me6 / pip180
IF temp
> 270 + lim_fy
THEN temp
= 270 + lim_fy
IF temp
< 270 - lim_fy
THEN temp
= 270 - lim_fy
me6
= temp
* pip180: me2
= me2
+ COS(-me6
) * actual_speed
* 5 * kw
+ 1 * ABS(ks
AND actual_speed
< .05) 'calculating Z actual_deep = (map_deep(me0, me1) - .1) * map_dimz
IF me2
> actual_deep
- .1 THEN me2
= actual_deep
- .1 - actual_speed
/ 4: me3
= me3
* .9: me4
= me4
* .9: flight
(af
, 17) = 1 ELSE flight
(af
, 17) = 0 IF me2
< flight_high_max
THEN me2
= flight_high_max
position_accel = .02: ww = .9999: szog_xy = me5 + rotx 'calculating XY
new_vec_x
= -SIN(szog_xy
) * position_accel
* kw: new_vec_y
= -COS(szog_xy
) * position_accel
* kw: vec_x
= (me3
* ww
+ new_vec_x
): vec_y
= (me4
* ww
+ new_vec_y
) vec_sum
= SQR(vec_x
* vec_x
+ vec_y
* vec_y
):
IF vec_sum
> position_speed
THEN vec_sum
= position_speed
/ vec_sum
ELSE vec_sum
= 1 me3
= vec_x
* vec_sum: me4
= vec_y
* vec_sum: me0
= me0
+ me3: me1
= me1
+ me4:
IF ks
THEN deacc
= .96 ELSE deacc
= .99:
IF kw
THEN deacc
= 1 me3 = me3 * deacc: me4 = me4 * deacc: flight(af, 16) = 0
IF crash_to_column
(me0
, me1
) THEN flight(af, 16) = 1
IF test
= 0 THEN me3
= -me3
* .7: me4
= -me4
* .7:
DO: m0
= m0
+ me3: me1
= me1
+ me4:
LOOP WHILE crash_to_column
(me0
, me1
) flight(af, 1) = rotx: flight(af, 3) = me0: flight(af, 4) = me1: flight(af, 5) = me2: flight(af, 6) = me3: flight(af, 7) = me4: flight(af, 2) = rotx_bevel3
flight(af, 12) = me6: flight(af, 13) = me5: flight(af, 15) = actual_speed
FUNCTION map_deep
(x
, y
): read_mapx1
= INT(x
+ map_resper2
) MOD map_resolution: read_mapx2
= INT(x
+ map_resper2
+ 1) MOD map_resolution
read_mapy1
= INT(y
+ map_resper2
) MOD map_resolution: read_mapy2
= INT(y
+ map_resper2
+ 1) MOD map_resolution
mapx1
= Interpolate
(map
(read_mapx1
, read_mapy1
, 0), map
(read_mapx2
, read_mapy1
, 0), me
(0) - INT(me
(0))) mapx2
= Interpolate
(map
(read_mapx1
, read_mapy2
, 0), map
(read_mapx2
, read_mapy2
, 0), me
(0) - INT(me
(0)))map_deep
= Interpolate
(mapx1
, mapx2
, me
(1) - INT(me
(1))):
END FUNCTION
FUNCTION crash_to_column
(x
, y
): pixs_column
= INT(map_dimxy
/ map_resolution
/ clmn_rad
) + 2 FOR tx
= -pixs_column
TO pixs_column:
FOR ty
= -pixs_column
TO pixs_column
read_mapx
= INT(x
+ map_resper2
+ tx
) MOD map_resolution: read_mapy
= INT(y
+ map_resper2
+ ty
) MOD map_resolution
FUNCTION degree
(a
, b
): degreex
= ATN((a
+ .00001) / (b
+ .00001)) / pip180: degreex
= degreex
- 180 * ABS(0 > b
): degreex
= degreex
- 360 * (degreex
< 0)