ok if this doesn't work I give up
hide mouse
rem Select font
set text font "arial" : set text size 16
set text to bold : set text transparent
rem Loading prompt
sync : center text screen width()/2,screen height()/2,"LOADING" : sync
wait 1000
rem Floor and Walls
make object box 1, 5000,0,5000
make object box 2, 10,500,2000
make object box 3, 10,500,2000
make object box 4, 1500,500,10
make object box 5, 2000,500,10
make object box 6, 5000,0,5000
make object box 7, 10,500,490
make object box 8, 1500,500,10
make object box 9, 100,500,5
make object box 10, 10,500,30
make object box 11, 10,500,30
make object box 13, 10,500,2490
rem Floor and Walls Collision Data
make object collision box 1, -2500,0,-2500,2500,0,2500,0
make object collision box 2, -5,-250,-1000,5,250,1000,0
make object collision box 3, -5,-250,-1000,5,250,1000,0
make object collision box 4, -750,-250,-5,750,250,5,0
make object collision box 5, -1000,-250,-5,1000,250,5,0
make object collision box 6, -2500,0,-2500,2500,0,2500,0
make object collision box 7, -5,-245,-200,5,250,245,0
make object collision box 8, -750,-250,-5,750,250,5,0
make object collision box 9, -50,-250,-2.5,50,250,2.5,0
make object collision box 10, -5,-250,-10,5,250,15,0
make object collision box 11, -5,-250,-10,5,250,15,0
make object collision box 13, -5,-250,-1245,5,250,1245,0
rem Walls Position
position object 2, 1000,250,0
position object 3, -1000,250,0
position object 4, 250,250,1000
position object 5, 0,250,-1000
position object 6, 0,500,0
position object 7, -495,250,1250
position object 8, -1250,250,1500
position object 9, 0,250,990
position object 10, 50,250,980
position object 11, -50,250,980
position object 13, -2002,250,250
rem Textures
load image "floor1.jpg",1
load image "brickwall1.jpg",2
load image "ceiling1.jpg",3
load image "ladder2.jpg",4
texture object 1,1 : scale object texture 1,2000,2000
texture object 2,2 : scale object texture 2,300,100
texture object 3,2 : scale object texture 3,300,100
texture object 4,2 : scale object texture 4,300,100
texture object 5,2 : scale object texture 5,300,100
texture object 6,3 : scale object texture 6,2000,2000
texture object 7,2 : scale object texture 7,100,100
texture object 8,2 : scale object texture 8,300,100
texture object 9,4 : scale object texture 9,100,1000
texture object 13,2 : scale object texture 13, 300,100
rem Gun
Load object "Guns.X\H-AK47-Static.x",12
lock object on 12
scale object 12,500,500,1000
position object 12,0.5,-1,1.5
disable object zdepth 12
rem Camera
set current camera 0
automatic camera collision 0,150,1
set global collision on
autocam off
rem Load all sounds
GunSnd=1 : load sound "gun.wav",GunSnd
ImpactSnd=2 : load 3dsound "impact.wav",ImpactSnd
DieSnd=3 : load sound "die.wav",DieSnd
EnemySnd=11 : load 3dsound "enemy.wav",EnemySnd
EnemygunSnd=12 : load 3dsound "enemygun.wav",EnemygunSnd
EnemydieSnd=13 : load 3dsound "enemydie.wav",EnemydieSnd
rem Load Enemy
EneObj=14
for ene=EneObj to EneObj+4
load object "Alien.X\H-Alien Mutant-move.x",ene : Scale object ene,10000,10000,10000 : make object collision box ene,-50,-50,-50,50,50,50,0
loop object ene,0,50
next ene
rem Place enemies throughout world and set BSP collision for them
aliensleft=0
restore EnemyPosData
for ene=EneObj to EneObj+4
read ex#,ey#,ez#
position object ene,ex#,ey#,ez#
set bsp object collision 3+(ene-EneObj),ene,0.75,0
yrotate object ene,180 : fix object pivot ene
inc aliensleft
next ene
rem Create object for bullet
BulletObj=23 : make object cube BulletObj,0.1
rem Load music (WAV best for looping)
MusicSnd=101 : load sound "ingame.wav",MusicSnd
loop sound MusicSnd : set sound volume MusicSnd,80
jump=0
rem loop
do
rem Movement
cx#=camera angle x (0) : cy#=camera angle y(0) : cz#=camera angle z(0)
if 17=scancode() then move camera 0,5
if 17=scancode() and shiftkey()=1 then move camera 0,10
if 31=scancode() then move camera 0,-2
if 30=scancode() then yrotate camera 0,cy#-90 : move camera 4 : yrotate camera 0,cy#
if 32=scancode() then yrotate camera 0,cy#+90 : move camera 4 : yrotate camera 0,cy#
if 201=scancode() then pitch camera up 0,5
if 209=scancode() then pitch camera down 0,5
if wrapvalue(camera angle x(0))>40 and wrapvalue(camera angle x(0))<180 then xrotate camera 0,40
if wrapvalue(camera angle x(0))>180 and wrapvalue(camera angle x(0))<335 then xrotate camera 0,335
rotate camera camera angle x(0)+(mousemovey()/5.0),camera angle y(0)+(mousemovex()/5.0),0
if spacekey()=1 and jump=0 then jump=1
rem Gravity
position camera camera position x(),camera position y()-0.5,camera position z()
FireImg=11 : load image "fire.bmp",FireImg
load image "crosshair.bmp",10
sprite 1,320-16,240-16,10
set sprite 1,0,1
rem Variable for finding closest enemy
cdist#=9999.99
rem Handle enemies within world
for ene=EneObj to EneObj+4
rem If enemy alive
if object visible(ene)=1
rem Kill this enemy
killenemy=0
rem Move enemy on a slow curve for appearance of intelegence
if object angle z(ene)=0
yrotate object ene,wrapvalue(object angle y(ene)+2)
endif
if object angle z(ene)=1
yrotate object ene,wrapvalue(object angle y(ene)-2)
endif
if object angle z(ene)=2
move object ene,0.05
else
move object ene,3
endif
rem Switch direction of curve based on a random value
if rnd(200)=1 then zrotate object ene,rnd(1)
rem Handle gravity for enemy
rem position object ene,object position x(ene),object position y(ene)-0.01,object position z(ene)
rem Work out angle and distance between enemy and player
dx#=camera position x(0)-object position x(ene)
dy#=camera position y(0)-object position y(ene)
dz#=camera position z(0)-object position z(ene)
dist#=abs(sqrt(abs(dx#*dx#)+abs(dy#*dy#)+abs(dz#*dz#)))
viewa#=wrapvalue(atanfull(dx#,dz#))
obja#=wrapvalue(object angle y(ene))
if viewa#>180 then viewa#=viewa#-360
if obja#>180 then obja#=obja#-360
rem If enemy 'facing player' and 'on similar height' and 'close', zoom in
if abs(viewa#-obja#)<10.0 and abs(dy#)<5.0 and dist#<30.0
if object angle z(ene)<>2 then play sound EnemygunSnd
rotate object ene,0,viewa#,2
set object speed ene,200
else
set object speed ene,100
endif
rem If enemy gets too close to player, player dies
if dist#<250.0
append object "Alien.X\H-Alien Mutant-Attack1.x",ene, total object frames (ene)+1
play sound DieSnd
for x=0 to 100
point camera object position x(ene), object position y(ene)+(x/20.0), object position z(ene)
sync
next x
restart=1
endif
rem Restart
if restart=1
restart=0
position camera (0),0,250,-500
endif
rem If enemy and bullet in same space, enemy dies
if bullet>0
if object collision(BulletObj,ene)>0
play sound EnemydieSnd
append object "Alien.x\H-Alien Mutant-Die.x",ene, total object frames (ene)+1
set object speed ene,100
bulletimpact=1
endif
endif
rem Closest enemy emits the enemy sound
if dist#<cdist#
cdist#=dist#
position sound EnemySnd,object position x(ene), object position y(ene), object position z(ene)
position sound EnemygunSnd,object position x(ene), object position y(ene), object position z(ene)
position sound EnemydieSnd,object position x(ene), object position y(ene), object position z(ene)
endif
rem Hide enemy when die animation over
if object frame(ene)>26+25 and object visible(ene)=1
killenemy=1
endif
if killenemy=1
hide object ene : dec aliensleft
killenemy=0
endif
rem If enemy alive ENDIF
endif
next ene
if mouseclick()=1 and bullet=-50
bullet=100
play sound GunSnd
position object BulletObj,camera position x(0),camera position y(0),camera position z(0)
rotate object BulletObj,camera angle x(0),camera angle y(0),camera angle z(0)
set bsp object collision 2,BulletObj,0.1,1
if particles exist(1)=1 then delete particles 1
make particles 1, FireImg, 50, 8.0
set particle emissions 1,10
set particle speed 1,0.01
move object BulletObj,100
endif
rem Control life of bullet
if bullet>0
rem If bullet collides with BSP world
if bsp collision hit(2)=1 or bulletimpact=1
rem End bullet on wall
position sound ImpactSnd,object position x(BulletObj), object position y(BulletObj), object position z(BulletObj)
play sound ImpactSnd
bulletimpact=0
bullet=0
else
rem Move bullet
dec bullet
move object BulletObj,25
set particle emissions 1,1+(bullet/10)
endif
rem Update particle using bullet object position
rotate particles 1,90-object angle x(BulletObj),object angle y(BulletObj)+180,0
position particles 1,object position x(BulletObj),object position y(BulletObj),object position z(BulletObj)
rem Bullet dies
if bullet=0
set particle emissions 1,0
set bsp collision off 2
endif
else
rem Gun recharge phase
if bullet>-50 then dec bullet
endif
rem Distance to next alien
if aliensleft>0 then text 20,screen height()-40,"DISTANCE READING:"+str$(abs(cdist#*100))
rem Aliens Left Stat
s$=str$(aliensleft)+" ALIENS LEFT"
if aliensleft=0 then s$="LEVEL COMPLETE!" : stop sound EnemySnd
text 640-20-text width(s$),screen height()-40,s$
rem end loop
loop
set global collision off
return
rem Enemy position data within level
EnemyPosData:
data -200,10,500
data -2300,10,-400
data 600,10,400
data -1200,10,0
data -2000,10,2000
as i said before just copy and paste the code straight into your new project and it will run fine, the models are from DarkMATTER and the sound files can either be recreated using your sound recorder or just delete that part of the code.
Any feed-back would be great.
Also here's a screenshot of how it should look at the start
if it doesn't look like this at the start something went wrong...
"Death is but an escape chosen by those who dare not live. I merely emancipate their souls." - Shadowblade, Master of Assassins.