Here you go:
gosub _load_game
rem Setup all objects for game
gosub _setup_game
rem Game loop
do
rem Control game elements
gosub _control_player
gosub _control_gun
gosub _control_health
gosub _control_fuel
rem gosub _control_enemies
rem gosub _hack_camera
gosub _gravity
rem In case of restart
if restart=1
restart=0
set bsp collision off 1
rotate camera 0,0,0
position camera 0,0,0
set bsp camera collision 1,0,0.75,0
fuel = 1000
health = 1000
BulletTimeout = 0
if levelno = 1
gosub _setup_level_1
rem if levelno = 2
rem gosub _setup_level_2
rem if levelno = 3
rem gosub setup_level_3
rem if levelno = 4
rem gosub setup_level_4
endif
endif
rem Update screen
sync
rem End loop
loop
rem End program
end
_load_game:
rem Load player model
PlayerObj = 11 : load object "models/hero/ROOMDEMO.x", PlayerObj
rem Load enemies
EneBugBotObj = 21 : load object "models/enemy/BugBot.3ds", EneBugBotObj
return
_setup_game:
rem Setup camera
set camera range 0.1,5000
set camera fov 50
autocam off
rem Setup sky model
SkyObj = 51 : load object "models\sky\am.x",SkyObj
set object SkyObj,1,0,0,0,0,0,0
scale object SkyObj,50,50,50
rem Setup player
lock object on PlayerObj
scale object PlayerObj, 8,8,10
rotate object PlayerObj, 270,90,0
position object PlayerObj, 0, -4, 32
rem Create bullet
BulletObj = 12 : make object cube BulletObj, 1
hide object BulletObj
rem Trigger player initialisation
levelno = 1
restart = 1
return