cls
set display mode 1280,1024,32
set window off
maximize window
sync on
sync rate 70
hide mouse
set text size 30
Ammo = 6
spareammo = 24
fog color rgb(28,28,0)
color backdrop rgb(28,28,28)
set dir "files"
load static objects "levelbank/testlevel/universe.dbo",0
set dir ".."
make object sphere 1,50 : hide object 1
position object 1,700,70,-600
load object "media/python.x",100
load image "media/Elite_tex.dds",50
texture object 100,50
YRotate Object 100,180
Fix object pivot 100
Scale object 100,125,75,100
position object 100,0,-10,15
Lock object on 100
rem bullet
Make object sphere 2,3
load image "textures/gold.bmp",40
Texture object 2,40
Hide object 2
rem ammo
load object "media/python_ammo.x",101
load image "textures/ammo.bmp",41
texture object 101,41
Load sound "music/gunsingleshot.wav",200
set sound volume 200,100
load sound "music/gunreload.wav",201
set sound volume 201,100
do
`record object position
x# = object position x(1)
z# = object position z(1)
rem y# = get ground height(1,x#,z#)
position object 1,x#,y#+70,z#
`Lets make sure the camera has a restricted y position (200 above the object)
position camera x#, y# + 50, z#
`camera rotate positions
crx#=camera angle x()
cry#=camera angle y()
crz#=camera angle z()
`mouse position
mx# = mousemovex()
my# = mousemovey()
crx# = wrapvalue(crx# + my#) : xrotate camera crx#
crz# = wrapvalue(crz# + my#) : zrotate camera crz#
if upkey()
x# = newxvalue(x#,cry#,4.0)
z# = newzvalue(z#,cry#,4.0)
rem y# = get ground height(1,x#,z#)
position object 1,x#,y#,z#
endif
if downkey()
x# = newxvalue(x#,cry#,-2.0)
z# = newzvalue(z#,cry#,-2.0)
rem y# = get ground height(1,x#,z#)
position object 1,x#,y#,z#
endif
`360 camera movement
rotate camera crx#+((my#+0.0)/10.0),cry#+((mx#+0.0)/10.0),0
if ammo > 0
If mouseclick()=1 and Bulletlife=0
set object to camera orientation 2
Position object 2,X#,Y#+20,Z#
Bulletlife = 100
Show object 2
play sound 200
damage = 25
ammo = ammo - 1
Endif
if bulletlife>0
Dec bulletlife
Move object 2,20
If bulletlife=0 then hide object 2
endif
endif
if spareammo > 1
enterkey = keystate(28)
if enterkey=1
play sound 201
spareammo =spareammo - (6-ammo)
ammo = 6
endif
endif
rem set text size
set cursor 1000,20
print "Ammo in gun: "; ammo
set cursor 1000,40
print "Ammo(spare): "; spareammo
if ammo = 0
set text size 70
set cursor 550,200
print "RELOAD";
set text size 30
ENDIF
position object 101,1150,30+(cos(a#)*10),-1100
s#=300+(cos(a#)*25)
scale object 101,s#,s#,s#
yrotate object 101,a#
inc a#,2.0
If Object hit(1,101)>0 then hide object 101: position object 101,-2000,0,-2000 : spareammo = spareammo + 12: set object collision off 101
sync
LOOP
This is my code currently, i am having problems putting it ino functions. I get so far but it doesnt work as well as it does when it doesnt use functions.
Any help?