Here's some lazer beam code from the author of Code Keeper,
remstart
Basic 'laser' Code, by Danny Wartnaby (aka Shivan on the forums)
you are completely welcome to use this in your games, all i ask
is a bit of credit for it. Thanks.
If you have any Q's you are welcome to e-mail me: [email protected]
or contact me by my website: www.dannywartnaby.co.uk
thanks for reading. enjoy.
remend
sync on
set camera range 1,26000
hide mouse
dim fired(40)
dim distance(40)
dim delay(1)
dim amount_of_bullets(1)
amount_of_bullets(1)=40
dim speed(1)
speed(1)=105
dim shipspeed(1)
make object cube 1,100
make object cube 2,33
make mesh from object 1,2
delete object 2
add limb 1,1,1
add limb 1,2,1
add limb 1,3,1
add limb 1,4,1
offset limb 1,1,60,-50,0
offset limb 1,2,40,-50,0
offset limb 1,3,-60,-50,0
offset limb 1,4,-40,-50,0
pitch camera up 1
Create_Weapon()
Create_Scene()
do
cx#=camera position x()
cy#=camera position y()
cz#=camera position z()
position object 4554,cx#,cy#,cz#
Fire_Weapon()
GUI()
move camera shipspeed(1)
if upkey()=1 then pitch camera up 1
if downkey()=1 then pitch camera down 1
if leftkey()=1 : turn camera left 1 : endif
if rightkey()=1 : turn camera right 1 : endif
if inkey$()="." then roll camera right 1
if inkey$()="," then roll camera left 1
sync
loop
FUNCTION Create_Weapon()
for t=1101 to amount_of_bullets(1) + 1100
Make object plain t,10,100
xrotate object t,90
color object t,rgb(0,125,255)
fix object pivot t
ghost object on t
set object t,1,0,0,0,0,0,0 : ` setting the object so it isn't affected by light, fog, ambient light... etc
ghost object on t
next t
for t=1201 to amount_of_bullets(1) + 1200
Make object plain t,10,100
color object t,rgb(0,125,255)
xrotate object t,90
fix object pivot t
ghost object on t
set object t,1,0,0,0,0,0,0
ghost object on t
next t
for t=1301 to amount_of_bullets(1) + 1300
Make object plain t,10,100
color object t,rgb(0,125,255)
xrotate object t,90
fix object pivot t
ghost object on t
set object t,1,0,0,0,0,0,0
ghost object on t
next t
for t=1401 to amount_of_bullets(1) + 1400
Make object plain t,10,100
color object t,rgb(0,125,255)
xrotate object t,90
fix object pivot t
ghost object on t
set object t,1,0,0,0,0,0,0
ghost object on t
next t
ENDFUNCTION
FUNCTION Fire_Weapon()
` the frame variable, is simply a place marker, for the object that 'surround's' the camera
` this is so, if you don't want it as object one (frame=1), you can change it to anything you see fit
` frame=7000 for example, and don't have to edit all the code. same applie's to the frame variable in
` the fire_weapon() function
frame=1
lx#=limb position x(frame, 1)
ly#=limb position y(frame, 1)
lz#=limb position z(frame, 1)
lx2#=limb position x(frame, 2)
ly2#=limb position y(frame, 2)
lz2#=limb position z(frame, 2)
lx3#=limb position x(frame, 3)
ly3#=limb position y(frame, 3)
lz3#=limb position z(frame, 3)
lx4#=limb position x(frame, 4)
ly4#=limb position y(frame, 4)
lz4#=limb position z(frame, 4)
cx#=camera position x()
cy#=camera position y()
cz#=camera position z()
position object frame,cx#,cy#,cz#
set object to camera orientation frame
for bullet=1 to amount_of_bullets(1)
if fired(bullet)=0
position object bullet+1100,lx#,ly#,lz#
position object bullet+1200,lx2#,ly2#,lz2#
position object bullet+1300,lx3#,ly3#,lz3#
position object bullet+1400,lx4#,ly4#,lz4#
set object to camera orientation bullet+1100
set object to camera orientation bullet+1200
set object to camera orientation bullet+1300
set object to camera orientation bullet+1400
endif
next bullet
for bullet=1 to amount_of_bullets(1)
if spacekey()=1
if fired(bullet)=0 and delay(1)=>150
position object bullet+1100,lx#,ly#,lz#
position object bullet+1200,lx2#,ly2#,lz2#
position object bullet+1300,lx3#,ly3#,lz3#
position object bullet+1400,lx4#,ly4#,lz4#
set object to camera orientation bullet+1100
set object to camera orientation bullet+1200
set object to camera orientation bullet+1300
set object to camera orientation bullet+1400
move object bullet+1100,50
move object bullet+1200,50
move object bullet+1300,50
move object bullet+1400,50
fired(bullet)=1
delay(1)=0
endif
endif
delay(1)=delay(1)+1
next bullet
for bullet=1 to amount_of_bullets(1)
if fired(bullet)=1
move object bullet+1100, speed(1)
move object bullet+1200, speed(1)
move object bullet+1300, speed(1)
move object bullet+1400, speed(1)
distance(bullet)=distance(bullet)+1
if distance(bullet)=>speed(1)
position object bullet+1100,lx#,ly#,lz#
position object bullet+1200,lx2#,ly2#,lz2#
position object bullet+1300,lx3#,ly3#,lz3#
position object bullet+1400,lx4#,ly4#,lz4#
set object to camera orientation bullet+1100
set object to camera orientation bullet+1200
set object to camera orientation bullet+1300
set object to camera orientation bullet+1400
distance(bullet)=0
fired(bullet)=0
endif
endif
next bullet
ENDFUNCTION
FUNCTION Create_Scene()
ink rgb(0,0,0),0
box 0,0,200,200
for t=1 to 45
ink rgb(255,255,255),0
dot rnd(199)+1,rnd(199)+1
next t
get image 1,0,0,200,200
make object sphere 4554,25000
texture object 4554,1
scale object texture 4554,11,11
set object 4554,1,1,0
ENDFUNCTION
FUNCTION GUI()
if inkey$()="=" then shipspeed(1)=shipspeed(1)+1
if inkey$()="-" then shipspeed(1)=shipspeed(1)-1
if shipspeed(1)=<0 then shipspeed(1)=0
if shipspeed(1)=>8 then shipspeed(1)=8
x=10 : y=300
box x,y,x+shipspeed(1)*3,y+5
ENDFUNCTION
It's pretty clever. With a little adaptation, it may be what you are looking for.
Enjoy your day.