CONST pip180
= 3.141592 / 180 CONST perlin_pers
= 8 '7 'amplitudo CONST perlin_level
= 4 '5 'level of resolution wave CONST perlin_multiplier
= 0.012 CONST perlin_smooth_noise_interpolation_type
= 0 '0-none '1-standard CONST perlin_flat_soil_limit_low
= .6 '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 * .8: mony = monx / 16 * 9 'screen size
win_marg = monx / 25
flight_high_max = -70
auto_precalc = 22
auto_mouse_scale = 120
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
pr_temp = 0 'temp pr
text_deep = 30 'make deep shadow pictures
map_center = 100000 'start of perlin-map
'text_field$ = "need\field2.bmp"
text_field$ = "field1.bmp" 'field map texture
text_multi = 40 'zoom to texture
position_speed = .3
map_resolution = 50 '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
DIM SHARED ee: ee
= map_dimxy
/ map_resolution
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.0003
'PREPARATION ---------------------------------------------------------------------------------------------------------------------------------------------------
'create wheel texture
whe_ts
= 50: whe_marg
= 7: temp
= _NEWIMAGE(whe_ts
, whe_ts
, 32):
_DEST temp:
CLS , 0: marg
= whe_ts
* text_size_marg
/ 100LINE (whe_marg
, whe_marg
)-(whe_ts
- whe_marg
, whe_ts
- whe_marg
), _RGBA32(100, 100, 100, 255), BF
'create pseudo random buffer
'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("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
'vehicle frame texture
marg
= 5:
LINE (marg
, marg
)-(vhfr_ts
- marg
, vhfr_ts
- marg
), _RGB32(255, 0, 0), BF:
_SETALPHA 0, _RGB32(255, 0, 0) TO _RGB32(255, 0, 0)
vp$ = "-01010-03010-01020-03020-00031-04031-01052-03052-01072-03072-00081-04081-00101-04101-00090-04090" 'points X(2),Y(2),Z(1)
vl$ = "-0001-0002-0103-0203-0004-0105-0204-0305-0406-0507-0607-0410-0511-0608-0709-0809-0810-0911-1011-1012-1113-1213-1412-1513-1415-0405-0214-0315" '3d lines
sq$ = "-0123-4567-0246-2367-3175-1054" 'cubes points make square
vt$ = "-000102031-000104051-141512131-101112131-040012141-050113151-080910111-141502031" 'bodywork textures
vt$ = vt$ + "-040610082-040509112-040506072-060708092" 'vehicle windows
vp$ = vp$ + "-01081-01101-01092-01102-03081-03101-03092-03102-00092-04092-00102-04102": vt$ = vt$ + "-161718193-202122233-242526270" 'extension air deflector
'create texture to map
FOR t
= 0 TO text_deep
- 1: dark
= (.6 - (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
'PREPARATION END ------------------------------------------------------------------------------------------------------------------------------------------
control_type = 0
veh_posx = map_center
veh_posy = map_center
old_camera_type = -1
camera_type = 0
gravity = .3
veh_gra = gravity
'-------------------------------------------------------- BOSS CYCLE -----------------------------------------------------------------------------------
'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
'keyboard/mouse inputs
IF ut_kf
= 0 AND kf
THEN control_type
= (control_type
+ 1) MOD 3 ut_kf = kf
me2_comp = me2_comp + mw * .1
'contol
IF pr_temp
THEN _PRINTSTRING (500, 0), "control type : " + control_type$
(control_type
) + " " control_type = 0
walk_speed = .18
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
me(0) = me(0) + go_x: me(1) = me(1) + go_y
' me(2) = (map_deep(me(0), me(1)) - .18 + mapzd) * map_dimz
'IF k_space AND free_jump THEN jump_cf = 15
'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
'camera control
IF camera_type
<> old_camera_type
THEN me2_comp = 0: dis_comp = 0
LOCATE 1, 1:
PRINT "VEHICLE CONTROL: arrow keys ,space-handbrake"
q$ = "camera height :mousewheel or *,- button , camera distance /,* button"
c$(0) = "typical view -" + q$
c$(1) = "interior view and mouse look around"
c$(2) = "'camera follows the car - " + q$
c$(3) = "free walking - WASD + mouse arrow " + q$
LOCATE 2, 1:
PRINT "camera type :"; camera_type;
"(change C button); " old_camera_type = camera_type
dis = (45 + dis_comp) / ee
me
(0) = SIN(veh_rotate1
) * dis
+ veh_posx
me
(1) = COS(veh_rotate1
) * dis
+ veh_posy
me(2) = map_deep(me(0), me(1)) * map_dimz - (2 + me2_comp) * ee
me(5) = (degree(veh_posx - me(0), veh_posy - me(1)) + 180) * pip180
me(6) = (degree(-(me(2) - veh_posz), dis)) * pip180 - (180 - 45) * pip180
me(5) = me(5) + (veh_rotate1 - me(5)) / 10
dis = 5 - 5.4 ' dis_comp = -5.2: me2_comp = 0.6
me
(0) = SIN(veh_rotate1
) * dis
+ veh_posx
me
(1) = COS(veh_rotate1
) * dis
+ veh_posy
me(2) = veh_posz - 12
me(6) = -(veh_rotate3 + pip180 * -90) - pip180 * 180 + veh_rotate3_mass
medismax = 3: medismin = 5: follow = .01
DO WHILE SQR((me
(0) - veh_posx
) ^ 2 + (me
(1) - veh_posy
) ^ 2) > medismax
me
(0) = me
(0) + SGN(veh_posx
- me
(0)) * follow: me
(1) = me
(1) + SGN(veh_posy
- me
(1)) * follow:
LOOP
DO WHILE SQR((me
(0) - veh_posx
) ^ 2 + (me
(1) - veh_posy
) ^ 2) < medismin
me
(0) = me
(0) - SGN(veh_posx
- me
(0)) * follow: me
(1) = me
(1) - SGN(veh_posy
- me
(1)) * follow:
LOOP
me(5) = (degree(veh_posx - me(0), veh_posy - me(1)) + 180) * pip180
me(2) = map_deep(me(0), me(1)) * map_dimz - (.5 + me2_comp) * ee
medis = 25: follow = .01
IF me
(0) <> veh_posx
THEN DO WHILE ABS(me
(0) - veh_posx
) > medis: me
(0) = me
(0) + SGN(veh_posx
- me
(0)) * follow:
LOOP IF me
(1) <> veh_posy
THEN DO WHILE ABS(me
(1) - veh_posy
) > medis: me
(1) = me
(1) + SGN(veh_posy
- me
(1)) * follow:
LOOP me(2) = map_deep(me(0), me(1)) * map_dimz - (1 + me2_comp) * ee
' LOCATE 3, 1: PRINT rotx_bevel
cosrotx
= COS(me
(6) - veh_rotate3
) sinrotx
= SIN(me
(6) - veh_rotate3
) ' rotx_bevel = veh_rotate2
' rotx_bevel = TIMER / 20 '* RND(1)
cosrotz
= COS(me
(5)): sinrotz
= SIN(me
(5)): cosrotx
= COS(me
(6)): sinrotx
= SIN(me
(6)) 'to rotating angles '------------------------------------------ TERRAIN DRAW --------------------------------------------------------------------------------------------------
'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
'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
):
NEXT map_y
, map_x
'TERRAIN DRAW END --------------------------------------------------------------------------------------------------------------------------------------------
'VEHICLE DRAW -------------------------------------------------------------------------------------------------------
v_ratio = .4 'car relativ size
veh_tengelytav = 4 * v_ratio: veh_kerektav = 4 * v_ratio: veh_kerekrad = 1 * v_ratio: veh_kerekszeles = .9 * v_ratio: veh_shockab_scale = .3
body_cx = .6 * v_ratio: body_cy = .6 * v_ratio: body_cz = .7 * v_ratio: frs = .08 * v_ratio: frs_dis_c = 1.1: body_yadd = -5.5 'frame size (ratio to vp$)
'draw wheel
wh_r(0) = veh_kerekrad: wh_r(1) = veh_kerekrad * .4: wh_div = 12 'wheel parameters
FOR a_wheel
= 0 TO 3: wh_posy
= (SGN(a_wheel
AND 1) * 2 - 1) * veh_tengelytav
/ 2: wh_posx
= (SGN(a_wheel
AND 2) * 2 - 1) * veh_kerektav
/ 2 wheel_ang
= (90 + ABS(a_wheel
AND 1) * veh_wheel
) * pip180
FOR awh
= 0 TO wh_div
- 1: ang
= (-wheel
(a_wheel
, 0) + 360 / wh_div
* awh
) * pip180: x
= SIN(ang
): y
= COS(ang
) FOR sz
= 0 TO 1: wh_z
= (sz
* 2 - 1) * veh_kerekszeles
/ 2:
FOR whr
= 0 TO 1: r1
= x
* wh_r
(whr
): r2
= wh_z: r3
= y
* wh_r
(whr
) rotate_2d r2, r1, wheel_ang: r1 = r1 + wh_posx: r2 = r2 + wh_posy: r3 = r3 + veh_shockab_scale * shockab(a_wheel)
rotate_vehicle r1, r2, r3, veh_rotate1, veh_rotate2, veh_rotate3: r1 = r1 + veh_posx: r2 = r2 + veh_posy: r3 = r3 * ee + veh_posz
rotate
(r1
- me
(0)) * ee
, (r2
- me
(1)) * ee
, r3
- me
(2), 0:
FOR t
= 0 TO 2: wang
(awh
, t
, whr
, sz
) = rotating
(t
):
NEXT t
, whr
, sz
, awh
p00
= t1: p01
= t4: p02
= t4: p10
= t2: p11
= t4: p12
= t4: p20
= t1: p21
= t3: p22
= t3
XOR 1: p30
= t2: p31
= t3: p32
= t3
XOR 1 _MAPTRIANGLE (0, 0)-(whe_ts
- 1, 0)-(0, whe_ts
- 1), whe_text
TO(wang
(p00
, 0, p01
, p02
), wang
(p00
, 1, p01
, p02
), wang
(p00
, 2, p01
, p02
))-(wang
(p10
, 0, p11
, p12
), wang
(p10
, 1, p11
, p12
), wang
(p10
, 2, p11
, p12
))-(wang
(p20
, 0, p21
, p22
), wang
(p20
, 1, p21
, p22
), wang
(p20
, 2, p21
, p22
)) _MAPTRIANGLE (whe_ts
- 1, whe_ts
- 1)-(whe_ts
- 1, 0)-(0, whe_ts
- 1), whe_text
TO(wang
(p30
, 0, p31
, p32
), wang
(p30
, 1, p31
, p32
), wang
(p30
, 2, p31
, p32
))-(wang
(p10
, 0, p11
, p12
), wang
(p10
, 1, p11
, p12
), wang
(p10
, 2, p11
, p12
))-(wang
(p20
, 0, p21
, p22
), wang
(p20
, 1, p21
, p22
), wang
(p20
, 2, p21
, p22
))
'draw vehicle frame
x1
= (VAL(MID$(vp$
, p1
* 6 + 2, 2)) - 2) * body_cx: y1
= -(VAL(MID$(vp$
, p1
* 6 + 4, 2)) + body_yadd
) * body_cy: z1
= -(VAL(MID$(vp$
, p1
* 6 + 6, 1))) * body_cz
x2
= (VAL(MID$(vp$
, p2
* 6 + 2, 2)) - 2) * body_cx: y2
= -(VAL(MID$(vp$
, p2
* 6 + 4, 2)) + body_yadd
) * body_cy: z2
= -(VAL(MID$(vp$
, p2
* 6 + 6, 1))) * body_cz
xc
= (x1
+ x2
) / 2: yc
= (y1
+ y2
) / 2: zc
= (z1
+ z2
) / 2: dis
= SQR((x1
- x2
) ^ 2 + (y1
- y2
) ^ 2 + (z1
- z2
) ^ 2) / 2 * frs_dis_c
angle1 = (-degree(x2 - x1, y2 - y1)) * pip180: angle2 = (degree(y2 - y1, z2 - z1) - 90) * pip180
rotate_2d p(t2, 0), p(t2, 1), angle1: rotate_2d p(t2, 1), p(t2, 2), -angle2: p(t2, 0) = p(t2, 0) + xc: p(t2, 1) = p(t2, 1) + yc: p(t2, 2) = p(t2, 2) + zc
rotate_vehicle p(t2, 0), p(t2, 1), p(t2, 2), veh_rotate1, veh_rotate2 + veh_rotate2_mass, veh_rotate3 + veh_rotate3_mass
r1 = p(t2, 0) + veh_posx: r2 = p(t2, 1) + veh_posy
r3
= (veh_posz
+ p
(t2
, 2) * ee
) - me
(2): rotate
(r1
- me
(0)) * ee
, (r2
- me
(1)) * ee
, r3
, 0:
FOR t
= 0 TO 2: p
(t2
, t
) = rotating
(t
):
NEXT t
, t2
_MAPTRIANGLE (0, 0)-(vhfr_ts
- 1, 0)-(0, vhfr_ts
- 1), vhfr_text
(0) TO(p
(sqv
(0), 0), p
(sqv
(0), 1), p
(sqv
(0), 2))-(p
(sqv
(1), 0), p
(sqv
(1), 1), p
(sqv
(1), 2))-(p
(sqv
(2), 0), p
(sqv
(2), 1), p
(sqv
(2), 2)) _MAPTRIANGLE (vhfr_ts
- 1, vhfr_ts
- 1)-(vhfr_ts
- 1, 0)-(0, vhfr_ts
- 1), vhfr_text
(0) TO(p
(sqv
(3), 0), p
(sqv
(3), 1), p
(sqv
(3), 2))-(p
(sqv
(1), 0), p
(sqv
(1), 1), p
(sqv
(1), 2))-(p
(sqv
(2), 0), p
(sqv
(2), 1), p
(sqv
(2), 2))
'draw vehicle bodywork textures
FOR t2
= 0 TO 3: vt
(t2
, 0) = (VAL(MID$(vp$
, vtx
(t2
) * 6 + 2, 2)) - 2) * body_cx: vt
(t2
, 1) = -(VAL(MID$(vp$
, vtx
(t2
) * 6 + 4, 2)) + body_yadd
) * body_cy
vt
(t2
, 2) = -(VAL(MID$(vp$
, vtx
(t2
) * 6 + 6, 1))) * body_cz:
rotate_vehicle vt(t2, 0), vt(t2, 1), vt(t2, 2), veh_rotate1, veh_rotate2 + veh_rotate2_mass, veh_rotate3 + veh_rotate3_mass
r1 = vt(t2, 0) + veh_posx: r2 = vt(t2, 1) + veh_posy: r3 = (veh_posz + vt(t2, 2) * ee) - me(2)
rotate
(r1
- me
(0)) * ee
, (r2
- me
(1)) * ee
, r3
, 0:
FOR t
= 0 TO 2: vt
(t2
, t
) = rotating
(t
):
NEXT t
, t2: atexture
= vhfr_text
(VAL(MID$(vt$
, t1
* 10 + 10, 1))) _MAPTRIANGLE (0, 0)-(vhfr_ts
- 1, 0)-(0, vhfr_ts
- 1), atexture
TO(vt
(0, 0), vt
(0, 1), vt
(0, 2))-(vt
(1, 0), vt
(1, 1), vt
(1, 2))-(vt
(2, 0), vt
(2, 1), vt
(2, 2)) _MAPTRIANGLE (vhfr_ts
- 1, vhfr_ts
- 1)-(vhfr_ts
- 1, 0)-(0, vhfr_ts
- 1), atexture
TO(vt
(3, 0), vt
(3, 1), vt
(3, 2))-(vt
(1, 0), vt
(1, 1), vt
(1, 2))-(vt
(2, 0), vt
(2, 1), vt
(2, 2))
'VEHICLE DRAW END ----------------------------------------------------------------------------------------------------------
'vehicle shockabs control
wheel_gc = 0: min_wh = 999999
r2
= (SGN(a_wheel
AND 1) * 2 - 1) * veh_tengelytav
* .3: r1
= (SGN(a_wheel
AND 2) * 2 - 1) * veh_kerektav
* .3: r3
= veh_shockab_scale
* shockab
(a_wheel
) rotate_vehicle r1, r2, r3, veh_rotate1, veh_rotate2, veh_rotate3: r1 = r1 + veh_posx: r2 = r2 + veh_posy: r3 = r3 * ee + veh_posz
dis_wheel(a_wheel, 0) = map_deep(r1, r2) * map_dimz 'a kerekek alatti talaj magassaga
dis_wheel(a_wheel, 1) = r3 'a kerek helyzete Z
dis_wheel(a_wheel, 2) = (dis_wheel(a_wheel, 0) - dis_wheel(a_wheel, 1) - 10) ' shockab(2) = .5 '0-bal hatso '1-bal elso '2-jobb hatso '3-jobb elso
wheel_gc
= wheel_gc
+ ABS(dis_wheel
(a_wheel
, 2) < 0): qw
= -0.2 IF dis_wheel
(a_wheel
, 2) < -1 THEN dis_wheel
(a_wheel
, 3) = qw
/ 2 ELSE dis_wheel
(a_wheel
, 3) = 0 IF dis_wheel
(a_wheel
, 2) < 1 THEN shockab
(a_wheel
) = shockab
(a_wheel
) - ABS(dis_wheel
(a_wheel
, 2)) * .02 shockab(a_wheel) = shockab(a_wheel) + .05
shockab(a_wheel) = shockab(a_wheel) * 1.01
IF shockab
(a_wheel
) > 1 THEN shockab
(a_wheel
) = 1 IF shockab
(a_wheel
) < 0 THEN shockab
(a_wheel
) = 0 IF dis_wheel
(a_wheel
, 2) < min_wh
THEN min_wh
= dis_wheel
(a_wheel
, 2): w_rot_neg
= a_wheel
zact = map_deep(veh_posx, veh_posy) * map_dimz - veh_kerekrad * ee
IF zact
< veh_posz
THEN veh_posz
= veh_posz
+ (zact
- veh_posz
) * .7: veh_vecz
= 0 ELSE veh_vecz
= veh_vecz
+ .06: veh_posz
= veh_posz
+ .3 vfly
= ABS(wheel_gc
< 2 AND ABS(veh_speed
) > .12): turn_rot
= 1
'vehicle Z-contol
ana_rad
= 3 * v_ratio: ang
= (veh_rotate1
): x1
= veh_posx
+ SIN(ang
) * ana_rad: y1
= veh_posy
+ COS(ang
) * ana_rad: m1
= map_deep
(x1
, y1
) * map_dimz
/ ee
x2
= veh_posx
- SIN(ang
) * ana_rad: y2
= veh_posy
- COS(ang
) * ana_rad: m2
= map_deep
(x2
, y2
) * map_dimz
/ ee
nofly_veh_rotate3
= (-degree
(m2
- m1
, ana_rad
* 2)) * pip180: veh_doles_power
= SIN(nofly_veh_rotate3
) ang
= (veh_rotate1
) + 90 * pip180: x1
= veh_posx
+ SIN(ang
) * ana_rad: y1
= veh_posy
+ COS(ang
) * ana_rad: m1
= map_deep
(x1
, y1
) * map_dimz
/ ee
x2
= veh_posx
- SIN(ang
) * ana_rad: y2
= veh_posy
- COS(ang
) * ana_rad: m2
= map_deep
(x2
, y2
) * map_dimz
/ ee
nofly_veh_rotate2 = (degree(m2 - m1, ana_rad * 2)) * pip180
qq_c
= .022: fly_veh_rotate2
= SGN(veh_rotate2_v
) * qq_c: fly_veh_rotate3
= SGN(veh_rotate3_v
) * qq_c: fly_veh_rotate1
= SGN(veh_rotate1
- veh_rotate1_last
) / 40
new_rotate3 = veh_rotate3 + fly_veh_rotate3 * ell: new_rotate2 = veh_rotate2 + fly_veh_rotate2 * ell: veh_rotate1 = veh_rotate1 + fly_veh_rotate1
veh_rotate2_v = dif_ang(veh_rotate2 / pip180, veh_rotate2_last / pip180, 360) * turn_rot
veh_rotate3_v = dif_ang(veh_rotate3 / pip180, veh_rotate3_last / pip180, 360) * turn_rot
veh_rotate3_last = veh_rotate3: veh_rotate2_last = veh_rotate2: veh_rotate1_last = veh_rotate1
new_rotate3 = nofly_veh_rotate3: new_rotate2 = nofly_veh_rotate2
veh_rotate2 = veh_rotate2 + (dif_ang(new_rotate2 / pip180, veh_rotate2 / pip180, 360)) * .009
veh_rotate3 = veh_rotate3 + (dif_ang(new_rotate3 / pip180, veh_rotate3 / pip180, 360)) * .009
'vehicle direction control
veh_speed_max = .6: veh_speed_min = .3
veh_wheel = veh_wheel + (k_left - k_right) * veh_wheel_sens
veh_wheel_max
= 70:
IF ABS(veh_wheel
) > veh_wheel_max
THEN veh_wheel
= SGN(veh_wheel
) * veh_wheel_max
veh_speed
= SQR(veh_vecx
^ 2 + veh_vecy
^ 2):
IF k_space
AND ABS(vfly
= 0) THEN gg
= 3 ELSE gg
= 1 veh_wheel = veh_wheel * (.85 - veh_speed / gg): wheel_speed_meas = -dif_ang(degree(vec_y, -vec_x), veh_rotate1 / pip180, 360)
IF k_space
THEN veh_rotate1_v_new
= vr1vn
* 1.01 ELSE veh_rotate1_v_new
= (veh_speed
* veh_wheel
) / 30 * SGN(wheel_speed_meas
) vr1vn
= veh_rotate1_v_new: korm_bef
= (1 - veh_speed
/ veh_speed_max
):
IF korm_bef
< .05 THEN korm_bef
= .05 veh_rotate1_v = veh_rotate1_v + (veh_rotate1_v_new - veh_rotate1_v) * korm_bef / 6
veh_rotate1_v = veh_rotate1_v * .999: veh_rotate1 = veh_rotate1 + veh_rotate1_v * veh_speed / veh_speed_max * 1
doles
= (1 - veh_doles_power
* .2) ^ 2: position_accel
= .0075 * 1 * (k_up
- k_down
) * ABS(k_space
= 0)
ww
= .98: new_vec_x
= SIN(veh_rotate1
) * position_accel: new_vec_y
= COS(veh_rotate1
) * position_accel: vdp
= (1 - veh_doles_power
/ 200) ^ 2 vec_x
= (veh_vecx
* ww
+ new_vec_x
) * vdp: vec_y
= (veh_vecy
* ww
+ new_vec_y
) * vdp: vec_sum
= SQR(vec_x
* vec_x
+ vec_y
* vec_y
) IF vec_sum
> veh_speed_max
AND SGN(wheel_speed_meas
) = 1 THEN vec_sum
= veh_speed_max
/ vec_sum
ELSE vec_sum
= 1
veh_vecx
= vec_x
* vec_sum: veh_vecy
= vec_y
* vec_sum: veh_speed
= SQR(veh_vecx
^ 2 + veh_vecy
^ 2) IF ((k_down
= 0 AND k_up
= 0) OR k_space
) AND veh_speed
< .02 THEN veh_vecx
= 0: veh_vecy
= 0: veh_speed
= 0
deacc
= .999:
IF k_space
THEN deacc
= .98 veh_vecx = veh_vecx * deacc: veh_vecy = veh_vecy * deacc
veh_posx = veh_posx + veh_vecx: veh_posy = veh_posy + veh_vecy: veh_posz = veh_posz + veh_vecz
'mass center
ang
= degree
(veh_vecx
, veh_vecy
) * pip180
- veh_rotate1: dis
= SQR(veh_vecx
^ 2 + veh_vecy
^ 2) veh_rotate2_mass
= -SIN(ang
) * dis
* .6: veh_rotate3_mass
= -COS(ang
) * dis
* .6 + -4.5 * pip180
'wheels rotation
FOR a_wheel
= 0 TO 3: wh_posy
= (SGN(a_wheel
AND 1) * 2 - 1) * veh_tengelytav
/ 2: wh_posx
= (SGN(a_wheel
AND 2) * 2 - 1) * veh_kerektav
/ 2 rotate_2d wh_posy
, wh_posx
, veh_rotate1: wheel_ang
= (90 + ABS(a_wheel
AND 1) * veh_wheel
) * pip180: add
= veh_speed:
IF add
> .2 THEN add
= .2 wheel
(a_wheel
, 0) = wheel
(a_wheel
, 0) + add
* 50 * SGN(wheel_speed_meas
):
NEXT a_wheel
'--------------------------------------------------------------------------- BOSS CYCLE END -------------------------------------------------
rotating_draw:
rd = .3
_MAPTRIANGLE (0, 0)-(whe_ts
- 1, 0)-(0, whe_ts
- 1), whe_text
TO(rotating
(0), rotating
(1), rotating
(2))-(rotating
(0) + rd
, rotating
(1), rotating
(2))-(rotating
(0), rotating
(1) + rd
, rotating
(2))
new_target: l
= 300: 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
FUNCTION perlin2d
(x
, y
): perlin2dx
= mapz_multiplier
* (Perlin2D_original
(x
, y
) - mapz_min
) ' perlin2d = 0: EXIT FUNCTION
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)
rotate_2d px3
, py2
, rotx_bevel: rotating
(0) = px3
* map_zoom_xy: rotating
(1) = -py3
* map_zoom_xy: rotating
(2) = pz3
* map_zoom_distance:
END SUB
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
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), x
- INT(x
)) mapx2
= Interpolate
(map
(read_mapx1
, read_mapy2
, 0), map
(read_mapx2
, read_mapy2
, 0), x
- INT(x
)) map_deep
= Interpolate
(mapx1
, mapx2
, y
- INT(y
))
' map_deep = (SIN(x10 / 500) + 1) / 2
FUNCTION degree
(a
, b
): degreex
= ATN((a
+ .00001) / (b
+ .00001)) / pip180: degreex
= degreex
- 180 * ABS(0 > b
): degreex
= degreex
- 360 * (degreex
< 0)
SUB rotate_vehicle
(p0
, p1
, p2
, a1
, a2
, a3
): rotate_2d p2
, p1
, a3
+ 180 * pip180: rotate_2d p0
, p2
, a2
+ 180 * pip180: rotate_2d p0
, p1
, -a1:
END SUB
FUNCTION dif_ang
(a
, b
, unit
): a2
= a: b2
= b