hide mouse
sync on
autocam off
titlescrn:
load image "titlescrn.bmp",1
paste image 1,1,1
do
set cursor 5,100
set text size 34
ink rgb(255,0,0),rgb(255,255,255)
print "i havent thought of a name of my game yet ill get back to you when i do aye"
print "press the spacebar to see the credits or the wkey to start the game"
if keystate(17)=1 then goto desertlv
loop
desertlv:
delete image 1
gosub load_level
gosub load_player
gosub load_camera
gosub load_enemies
sync rate 1000
rem --------------------------------MAIN LOOP------------------\
rem ===================================================================
do
gosub player_control
gosub enemy_control
if gun#=1 then gosub pistol
if gun#=2 then gosub sniper
sync
loop
rem -------------------------------loading the desert level---------
load_level:
load object "desert.x",1
load object "complex.x",2
position object 1,1,-10,1
position object 2,50,20,50
set object 1,1,1,1
set object 2,1,0,1
set object collision on 1
set object collision on 2
return
load_camera:
playerx# = object position x(5)
playery# = object position y(5)
playerz# = object position z(5)
position camera playerx#,playery#,playerz#
set camera range 1,5000
fog on
fog distance 4000
make object plain 4,5,5
position object 4,0,0,200
lock object on 4
color object 4,rgb(255,0,150)
ghost object on 4
set object 4,1,1,0
load image "backdrop.bmp",1
texture backdrop 1
delete image 1
fov#=1
return
load_player:
make object sphere 5,10
hide object 5
set object 5,1,0,1
position object 5,50,50,10
set camera to object orientation 5
bulletalive#=1
load image "bullet.bmp",6
load sound "gunfire.wav",6
load sound "pistolreload.wav",7
gun#=1
pistolammo#=10
set object collision on 5
return
load_enemies:
load object "obj1.x",7
load object "enemy2.x",8
load object "enemy3.x",9
scale object 7,1000,1000,1000
position object 7,500,50,50
position object 8,100,20,1000
position object 9,2000,20,1000
set object 7,1,0,1
set object 8,1,0,1
set object 9,1,0,1
set object collision on 7
set object collision on 8
set object collision on 9
return
rem -----------------------------main loop gosubs-----------------
rem ----------------------------------------------------------
player_control:
position mouse 320,240
cx#=wrapvalue(cx#+mousemovey()*fov#)
cy#=wrapvalue(cy#+mousemovex()*fov#)
cz#=wrapvalue(cz#+mousemovez()*fov#)
yrotate object 5,cy#
xrotate object 5,cx#
zrotate object 5,cz#
rotate camera cx#,cy#,cz#
oldx#= object position x(5)
oldy#= object position y(5)
oldz#= object position z(5)
if oldy#>50 then oldy#=50
if oldy#<50 then oldy#=50
if keystate(17)=1
move object 5,10
endif
if keystate(31)=1
move object 5,-10
endif
if keystate(30)=1
turn object right 5,cy#-90
move object 5,10
turn object right 5,cy#+90
endif
if keystate(32)=1
turn object right 5,cy#+90
move object 5,10
turn object right 5,cy#-90
endif
playerx#=object position x(5)
playery#=object position y(5)
playerz#=object position z(5)
if playery#>50 then playery#=50
if playery#<50 then playery#=50
position object 5,playerx#,playery#,playerz#
if object collision(5,7)=1
position object 5,oldx#,oldy#,oldz#
endif
if object collision(5,0)=1
position object 5,oldx#,oldy#,oldz#
endif
if keystate(2)=1
gun#=1
set camera fov 1
endif
if keystate(3)=1 then gun#=2
newx# = object position x(5)
newy# = object position y(5)
newz# = object position z(5)
position camera newx#,newy#,newz#
return
rem -------------------------------zooming-----------------(+)
sniper:
if mouseclick()=1 and bulletalive#=1
make object sphere 16,5
texture object 16,6
position object 16,playerx#,playery#,playerz#
set object to camera orientation 16
set object collision on 16
set object collision to spheres 16
bulletalive#=60
play sound 6
endif
if bulletalive#>2
move object 16,1000
bulletalive#=bulletalive#-1
endif
if bulletalive#<5 and bulletalive#>2
delete object 16
bulletalive#=1
endif
if downkey()=1
fov#=fov#+0.03
endif
if upkey()=1
fov#=fov#-0.03
endif
if fov#=0.05 or fov#<0.05 then fov#=0.05
if fov#>1 then fov#=1
set camera fov fov#
return
rem -------------------------------pistol control------------
pistol:
reloading#= sound playing(7)
if mouseclick()=1 and bulletalive#=1 and reloading#=0
make object sphere 6,5
texture object 6,6
position object 6,playerx#,playery#,playerz#
set object to camera orientation 6
set object collision on 6
set object collision to polygons 6
bulletalive#=20
ammopistol#=ammopistol#-1
play sound 6
endif
if bulletalive#>2
move object 6,1000
bulletalive#=bulletalive#-1
endif
if bulletalive#<5 and bulletalive#>2
delete object 6
bulletalive#=1
endif
if ammopistol#<1
play sound 7
ammopistol#=10
endif
if bulletalive#<1
if object collision(6,7)=1
delete object 6
bulletalive#=1
endif
endif
return
rem -----------------------------enemy control-----------------
enemy_control:
point object 7,newx#,newy#,newz#
move object 7,4
if bulletalive#>1
if object collision(6,7)=1
color object 7,rgb(255,0,0)
endif
endif
return
i hope this helps
ps if anyone can be bothered lookiing through this code it is a basic fps engine and is worth a look if you want to
cheers if this helps
me
darkhorsegames.tk coming soon