@Baggers -- sorry about that, My posts don't automatically post when I post them, I'm still "Untrusted." (grumble... takes to long... grumble"
Anyway, I've got another issue. I've been progressing merrily along since my last post, and now my ship can shoot bullets and hit the 'roids.
What I want to happen is for the 'roids to fly off once the bullets hits them. I tried to do this by making the 'roids face the bullet and then scuttle off backwards, but they are not behaving as I would expect. Can any one tell me if this is a simple bug in my exsiting code? (I doubt it) Or can anyone suggest a better way to do this?
Anyway, here's the complete code, it dosn't need any media so go ahead and try it out.
Rem Author: Ethan Roberts, Lame Brain Productions
Rem Project: StarWheezer
Rem Created: 4/26/2005 3:47:59 PM
Rem ***** Varible Setup and General Maintenance*****
randomize timer()
set display mode 640,480,16
help = 1
Rem ***** Instruction page *****
if help = 1
Cls
ink rgb(0,250,0),0
set text size 48
text 1,10, "Controls"
ink rgb(0,0,250),0
set text size 12
center text 320,30, "SPEED CONTROLS"
center text 320,45, "` = speed 0"
center text 320,60, "1 = speed 1"
center text 320,75, "2 = speed 2"
center text 320,90, "3 = speed 3"
center text 320,105, "4 = speed 4"
center text 320,120, "5 = speed 5"
center text 320,135, "6 = speed 6"
center text 320,150, "7 = speed 7"
center text 320,165, "8 = speed 8"
center text 320,180, "9 = speed 9"
center text 320,195, "0 = speed 10"
ink rgb(150,150,150),0
center text 320, 225, "MANUAL CONTROLS"
center text 320, 240, "Shift+W = Slide Up"
center text 320, 255, "Shift+A = Roll Left"
center text 320, 270, "Shift+D = Roll Right"
center text 320, 285, "Shift+S = Slide Down"
ink rgb(250,0,0),0
center text 320, 315, "MORE MANUAL CONTROLS"
center text 320, 330, "These controls only work at Speed 0"
center text 320, 345, "W = Forward"
center text 320, 360, "A = Slide Left"
center text 320, 375, "D = Slide Right"
center text 320, 390, "S = Backward"
ink rgb(50,100,100),0
center text 320, 420, "And press Space to fire your Cannon"
ink rgb(50,50,50),0
text 1, 450, "Now, press any key to play... !!!"
ink rgb(250,250,250),0
text 240, 450, "STAR WHEEZER"
suspend for key
endif
Backdrop on
sync off
color backdrop rgb(0,0,0)
autocam off
hide mouse
set point light 0, 0,0,0
set light range 0, 10000
set camera range 1, 20000
Dim shot(101)
Dim roid(101)
Dim active_shot(101)
Dim active_roid(101)
Dim Active_Shot_Life(101)
Dim Roid_speed(101)
Global Number_Shots: Number_Shots = 0
Global Number_Roids: Number_Roids = 0
Global speed: speed = 0
t = 26
Rem ***** Object Setup *****
Rem Camera object
make object sphere 1, 50
Rem Asteroids or whatever
for a = 101 to 201
Make object sphere a,50
roid(a-100) = a
active_roid(a-100) = 0
roid_speed(a-100) = 0
rotate object a, rnd(360), rnd(360), rnd(360)
move object a,rnd(9000)+1000
color object a, rgb(128,64,0)
next a
Rem Bullets or whatever
for a = 1001 to 1101
make object sphere a, 5
color object a, rgb(100,100,255)
shot(a-1000) = a
active_shot(a-1000) = 0
hide object a
next a
Rem ***** Main loop *****
Do
Rem <Mouse controls>
CX = mousemovex()
CY = mousemovey()
if cx <> 0 then turn object right 1, cx
if cy <> 0 then pitch object down 1, cy
Rem </Mouse controls>
Rem <Manual Controls> (only work when speed = 0)
Rem W = forward, S = Backward, A = Slide Left, D = Slide Right
if speed = 0
if scancode() = 17 and shiftkey() = 0 then move object 1, 1
if scancode() = 30 and shiftkey() = 0 then move object left 1, 1
if scancode() = 31 and shiftkey() = 0 then move object 1, -1
if scancode() = 32 and shiftkey() = 0 then move object right 1, 1
endif
Rem </Manual Controls>
Rem <More Manual Controls> (these work regardless of speed)
Rem Shift+W = Slide up, Shift+S = Slide down, Shift+A = Roll left, Shift+D = roll right
if speed = 0
s = 1
else
s = speed
endif
if scancode() = 17 and shiftkey() = 1 then move object up 1, s
if scancode() = 30 and shiftkey() = 1 then Roll object left 1, .5
if scancode() = 31 and shiftkey() = 1 then move object down 1, s
if scancode() = 32 and shiftkey() = 1 then roll object right 1, .5
Rem </More Manual Controls>
Rem <Speed Controls>
if scancode() = 41 then speed = 0
if scancode() = 2 then speed = 1
if scancode() = 3 then speed = 2
if scancode() = 4 then speed = 3
if scancode() = 5 then speed = 4
if scancode() = 6 then speed = 5
if scancode() = 7 then speed = 6
if scancode() = 8 then speed = 7
if scancode() = 9 then speed = 8
if scancode() = 10 then speed = 9
if scancode() = 11 then speed = 10
` move camera speed
move object 1, speed
Rem </Speed Controls>
Rem <Gun>
if spacekey() = 1 and Number_Shots <= 101
if t > 25
t = 0
inc Number_Shots
active_shot(Number_Shots) = Number_Shots + 1000
show object active_shot(Number_Shots)
position object active_shot(Number_Shots), object position x(1), object position y(1), object position z(1)
set object to camera orientation active_shot(Number_Shots)
move object down active_shot(Number_Shots), 25
move object active_shot(Number_Shots), 10
Active_Shot_Life(Number_Shots) = 0
endif
endif
Rem This is the firing delay
if t < 27 then inc t
if Number_Shots > 0
for a = 1 to Number_Shots
move object active_shot(a), 12
inc Active_Shot_Life(a)
Rem This sorts the bullet list
if Active_Shot_Life(a) > 2500 and a <> Number_Shots
position object active_shot(a), -40000,40000,-40000
for b = a to Number_Shots
active_shot(b) = active_shot(b+1)
active_shot_life(b) = active_shot_life(b+1)
next b
dec Number_Shots
endif
Rem this just docks the last bullet
if Active_Shot_Life(a) > 2500 and a = Number_Shots
position object active_shot(a), -40000,40000,-40000
dec Number_Shots
endif
Rem Collision Detection
hit = object hit(active_shot(a),0)
if hit > 0
Rem if bullet hit a roid
if hit > 100 and hit < 202
inc Number_roids
num = Number_roids
Active_roid(Num) = hit
roid_speed(num) = 12
point object hit, object position Z(active_shot(a)), object position Y(active_shot(a)), object position Z(active_shot(a))
endif
Rem Remove the bullet
position object active_shot(a), -40000,40000,-40000
for b = a to Number_Shots
active_shot(b) = active_shot(b+1)
active_shot_life(b) = active_shot_life(b+1)
next b
dec Number_Shots
endif
next a
endif
Rem </Gun>
Rem <Roids>
if Number_Roids > 0
Rem Only active Roids move
for a = 1 to Number_Roids
move object active_roid(a), (Roid_Speed(a))*-1
Rem a Roid's speed will degrade
if roid_speed(a) > 0 then dec roid_speed(a)
Rem if a Roid's speed drops to zero, that roid is no longer active.
if roid_speed(a) = 0 and a <> Number_Roids
for b = a to Number_Roids
active_roid(b) = active_roid(b+1) `shifts the array
next b
dec Number_Roids `decreases the number of Roids that are active
endif
Rem if a roid stops, and it is the last one moving, then this happens:
if roid_speed(a) = 0 and a = Number_Roids then dec Number_Roids
next a
endif
Rem </Roids>
Rem <Light>
position light 0, camera position x(0), camera position y(0), camera position z(0)
Rem </Light>
Rem <Other>
text 1,1,str$(Screen fps())
position camera object position x(1), object position y(1), object position z(1)
rotate camera object angle x(1), object angle y(1), object angle z(1)
Rem </Other>
Loop
--Thanx!
Another hair-brained idear from... LAME BRAIN!