In my space simulator game, i have a space particle effect, which uses randomly placed spheres to give you a sense of movement. It works perfectly for about a minute and then all the spheres randomly change position and it looks crap. Run it for a few minutes and you'll see what i mean:
rem sync on
sync on
sync rate 40
rem display mode
set display mode 1024, 768, 32
rem load sub
gosub load
rem vars
gosub var
rem load IDRON
gosub IDRON:
rem main loop
do
rem ship pos
x# = object position x(1001)
y# = object position y(1001)
z# = object position z(1001)
rem ship angles
Xangle# = object angle x(1001)
yangle# = object angle y(1001)
zangle# = object angle z(1001)
oldthrust# = thrust#
if leftkey()
turn object left 1001, turn_speed#
endif
if rightkey()
turn object left 1001, -1 * turn_speed#
endif
if upkey()
pitch object up 1001, -1 * turn_speed#
endif
if downkey()
pitch object up 1001, turn_speed#
endif
rem movement
if spacekey()
if thrust# < max_speed#
thrust# = thrust# + acceleration#
endif
endif
if controlkey()
if thrust# > min_speed#
thrust# = thrust# - acceleration#
endif
endif
if shiftkey() and thrust# > 0
stop# = 1
endif
if wep_installed# = 1
if inkey$() = "z"
gosub add_shoot
endif
endif
rem go to slow down sub if stop = 1
gosub slowdown
rem go to the hud sub
gosub hud
rem move shoot stuff
gosub shoot_move
rem do system specific stuff
gosub system_sub
rem space particles
gosub space_particles
rem move ship
move object 1001, thrust#
rem move sky box(so you can't go through it)
position object 1, object position x(1001), object position y(1001), object position z(1001)
rem position the camera
position camera object position x(1001),object position y(1001),object position z(1001)
set camera to object orientation 1001
pitch camera down 30
move camera -20
sync
loop
hud:
text 20, 660, str$(int(thrust# * 100)) + " M/S"
return
system_sub:
if specific$ = "IDRON" then gosub IDRON_SPEC
return
var:
rem camera distance dealy
set camera range 1, 50000
rem ship controllability
turn_speed# = 0.5
max_speed# = 2
min_speed# = -0.02
acceleration# = 0.05
wep_installed# = 1
max_fire = 40
dim bullet_time(max_fire)
dim ran(3)
rem hud dealies
set text opaque
return
slowdown:
if thrust# =< 0
stop# = 0
thrust# = 0
endif
if stop# = 1
thrust# = thrust# - (acceleration# * 4)
endif
return
load:
rem bitmap dealy
set current bitmap 0
rem ink color white
ink rgb(255, 255, 255), 0
rem load images
load image "idron.png", 1
load image "hud.png", 2
rem place hud images
sprite 2, 10, 650, 2
rem load ships
load object "ship.x", 1001
rem skybox(actually its a sphere, but what the heck)
make object sphere 1, -10000
rem texture skybox
texture object 1, 1
rem engine
make object sphere 2, 0.2
make object sphere 3, 0.2
make object sphere 4, 0.1
make object sphere 5, 0.1
position object 2, 1, -1, -2
position object 3, 1, 1, -2
position object 4, -1, 1, -2
position object 5, -1, -1, -2
color object 2, rgb(255, 255, 255)
color object 3, rgb(255, 255, 255)
color object 4, rgb(255, 255, 255)
color object 5, rgb(255, 255, 255)
make mesh from object 2, 2
make mesh from object 3, 3
make mesh from object 4, 4
make mesh from object 5, 5
add limb 1001, 1, 2
add limb 1001, 2, 3
add limb 1001, 3, 4
add limb 1001, 4, 5
return
add_shoot:
for n = 6000 to max_fire + 6000
if object exist(n) = 0
make object sphere n, 1
color object n, rgb(0, 255, 0)
position object n, x#, y#, z#
rotate object n, xangle#, yangle#, zangle#
endif
next n
return
shoot_move:
for n = 6000 to max_fire + 6000
if object exist(n) = 1
move object n, 4
bullet_time(n - 6000) = bullet_time(n - 6000) + 20
if bullet_time(n - 6000) > 80
delete object n
bullet_time(n - 6000) = 0
endif
endif
next n
return
space_particles:
for n = 200 to 250
if object exist(n) = 0
make object sphere n, 0.5
ghost object on n
position object n, x#, y#, z#
for n2 = 1 to 3
flag = rnd(1)
if flag = 1
Ran(n2) = rnd(20)
else
ran(n2) = -1 * rnd(20)
endif
next n
rotate object n, wrapvalue(object angle x(1001) + Ran(1)), wrapvalue(object angle y(1001) + Ran(2)), wrapvalue(object angle z(1001) + Ran(3))
move object n, rnd(200)
set object to camera orientation n
else
if object in screen(n) = 0
delete object n
endif
endif
next n
return
rem Systems
IDRON:
make object sphere 10, 1000
color object 10, rgb(200, 30, 30)
make light 1
set light range 1, 10000
make object sphere 11, 200
position object 11, 1500, 0, 500
make object sphere 12, 400
position object 12, -3000, 0, -200
return
IDRON_SPEC:
return
The space particle bit is in the space_particles sub
What's wrong with it?
<> <> EVIL....
---
Untitled Space Sim: 10%