Sync on
Sync rate 60
Hide mouse
Load image "media/stars.jpg",1
REM load sounds
gamestate = 0
REMStart
Object Number Index
1: PLayer
2-4: Shots
5-50: Enemies
100: Background
Gamestate index
0: Menu
1: Game
REMend
yy=300
xx=10
shoot = 0
Show_Menu()
wait key
if inkey$() = "2"
end
endif
game()
end
function Show_Menu
gamestate = 0
Set Cursor 100,100:print "Select Option"
Set Cursor 100,200:print "1 : Start Game"
Set Cursor 100,300:print "2 : Exit"
sync
endfunction
function game
gamestate = 1
cls
create_player()
create_enemies()
pitch camera down 90
do
if inkey$() = "["
end
endif
Draw_HUD()
get_input()
Move_Bullets()
Camera()
loop
EndFunction
function create_player()
if object exist(1)
delete object 1
endif
if object exist(2)
delete object 2
endif
make object cube 1,10
color object 1,RGB(255,0,0)
make object cube 2,5
hide object 2
scale object 2,50,50,250
color object 2,RGB(0,255,0)
make object cube 3,5
hide object 3
scale object 3,50,50,250
color object 3,RGB(0,255,0)
make object cube 4,5
hide object 4
scale object 4,50,50,250
color object 4,RGB(0,255,0)
REM texture object 1,(player ship picture)
position object 1,100,0,-400
make object sphere 100,-2000
texture object 100,1
bulletlife2 = 0
bulletlife3 = 0
bulletlife4 = 0
shot_speed = 15
gamestate = 1
endfunction
function create_enemies
for e = 8 to 50
make object cube e,10
position object e,xx,0,yy
xx= xx + 20
enemy_line_count = enemy_line_count + 1
if enemy_line_count = 15
yy=yy-75:xx=10
enemy_line_count = 0
endif
enemy_count = enemy_count + 1
color object e,RGB(0,255,0)
REM texture object e,(enemy ship picture)
next e
EndFunction
Function Move_Bullets
if shoot > 0
move object 2,shot_speed
bulletlife2 = bulletlife2 + 1
endif
if shoot > 1
move object 3,shot_speed
bulletlife3 = bulletlife3 + 1
endif
if shoot > 2
move object 4,shot_speed
bulletlife4 = bulletlife4 + 1
endif
if bulletlife2 = 60
shoot = shoot - 1
bulletlife2 = 0
hide object 2
Endif
if bulletlife3 = 60
shoot = shoot - 1
bulletlife3 = 0
hide object 3
endif
if bulletlife4 = 60
shoot = shoot - 1
hide object 4
endif
EndFunction
Function Create_Powerup
make object cube 8,10
color object 8,RGB(0,255,0)
EndFunction
Function Draw_HUD
set text font "Times New Roman"
set text to bold
set cursor 0,0:print "",screen fps()
set cursor 100,0:print "SCORE : ",score
set cursor 200,0:print "TRIES : ",tries
set cursor 300,0:Print "X : ",camera position x(0)
set cursor 350,0:Print "Y : ",camera position y(0)
set cursor 400,0:Print "Z : ",camera position z(0)
set cursor 500,0:Print "",inkey$()
EndFunction
Function Camera
position camera 100,370,-120
point camera 100,0,90
Sync
EndFunction
Function get_input
rem If gamestate = 1
if leftkey() = 1
if object position x(1)>0 then move object left 1,3
endif
if rightkey() = 1
if object position x(1)<300 then move object right 1,3
endif
if spacekey() = 1 and shoot < 3
position object (shoot + 2),object position x(1),0,object position z(1):show object (shoot + 2)
shoot = shoot + 1
endif
rem endif
endfunction
There we go, thanks =)