bluatigro
Jul 21, 2010
WindowHeight = DisplayHeight
global winx , winy
winx = WindowWidth
winy = WindowHeight
global px , py , pst , lastkey$ , pi , q , d , joyYN$ ,
global points , lives , state , ufohasfired , level ,
global true ,
global sndPlayerFire$ , sndPlayerWasHit$ ,
global sndUfoWasHit$ ,
global notjetactif , flies ,
notjetactif = 0
flies = 1
washit = 2
global rockmax ,
dim rockdx( 8 ) , rockdy( 8 ) , rockst( 8
false = 0
true = not( false
pi = atn( 1 ) *
level = 0
for i = 0 to
loadbmp "p";i , DefaultDir$ + "\BMP\player" + nr$( i ) +
anim$
next i
loadbmp "fire" , DefaultDir$ +
loadbmp "rock" , DefaultDir$ +
loadbmp "ufo" , DefaultDir$ +
loadbmp "star" , DefaultDir$ +
notice chr$( 13 )
+ "Blua tigro presents :" + chr$( 13 )
+ "ASTERIODS ." + chr$( 13 )
+ "use cursor keys" + chr$( 13 )
+ "to move your ship" + chr$( 13 )
+ "spacebar : fire ." + chr$( 13 )
+ "[esc] : quit game ." + chr$( 13 )
+ "rock : 2 points ." + chr$( 13 )
+ "ufo : 7 points
readjoystick 1
if joy1x > 2
confirm chr$( 13 )
+ "Joystick detected . " + chr$( 13 )
+ "Use joystick ?" ;
end if
''graphicbox #m.g , 0 , 0 , winx ,
nomainwin
open "asteriods" for graphics as
#m "trapclose
#m "when characterInput
#m "fill
#m "backcolor
#m "color
#m "getbmp back 0 0 " ; winx ; " " ;
#m "background
for i = 0 to
#m "addsprite star" ; i ; "
#m "spritexy star"; i ; " "
; rnd( 0 ) * winx ; " " ; rnd( 0 ) *
#m "spritescale star"; i ; " " ; rnd( 0 ) ^ 3 *
#m "spritemovexy star" ; i ; " 0
next i
for i = 0 to
#m "addsprite live" ; i ; " p" ;
#m "spritexy live" ; i ; " " ; i * 50 ; " " ; winy -
#m "spritescale live"; i ; "
next i
for i = 0 to
#m "addsprite playerfire" ; i ; "
#m "spritexy playerfire" ; i ; " -100
next i
for i = 0 to
#m "addsprite rock" ; i ; "
next i
#m "spritescale rock0
#m "spritescale rock1
#m "spritescale rock2
#m "spritescale rock3
#m "spritescale rock4
#m "spritescale rock5
#m "spritescale rock6
#m "addsprite ufo
#m "addsprite ufofire
#m "setfocus"
#m "addsprite player " ;
#m "spritexy player " ; px ; " " ;
call nextlevel
call drawpoints
timer 40 ,
wait
function nr$( no
nr$ = right$( "00" + str$( no ) , 2
end function
[tmr]
q = q -
if q < 0
q = int( rnd( 0 ) * 20
d = int( rnd( 0 ) * 3
end if
if joyYN$ = "yes"
if joy1x < 256 * 256 / 3
pst = ( pst + 1
if pst > 31 then pst =
end if
if joy1x > 256 * 256 * 2 / 3
pst = ( pst - 1
if pst < 0 then pst =
end if
if joy1y < 256 * 256 / 3
px = ( px - sin( strad( pst ) ) * 5
if px < -100 then px =
if px > winx then px =
py = ( py - cos( strad( pst ) ) * 5
if py < -100 then py =
if py > winy then py =
end if
if joy1y > 256 * 256 * 2 / 3
''here i wil place a hyperjump in the
end if
else
select case lower$( lastkey$
case chr$( _VK_LEFT
pst = ( pst + 1
if pst > 32 then pst =
case chr$( _VK_RIGHT
pst = ( pst - 1
if pst < 0 then pst =
case chr$( _VK_UP
px = ( px - sin( strad( pst ) ) * 5
if px < -100 then px =
if px > winx then px =
py = ( py - cos( strad( pst ) ) * 5
if py < -100 then py =
if py > winy then py =
case chr$( _VK_DOWN
''hyperjump
case chr$( 27 )
goto [quit]
wait
case " "
#m "spritexy playerfire" ; firetel ; " "
; px - 16 - sin( strad( pst ) ) * 45 ; " "
; py - 16 - cos( strad( pst ) ) *
#m "spritemovexy playerfire" ; firetel ; " "
; sin( strad( pst ) ) * -6 ; " "
; cos( strad( pst ) ) *
firetel
if firetel > 20 then firetel =
end select
end if
lastkey$ = ""
#m "spritexy player " ; px - 50 ; " " ; py -
#m "spriteimage player p" ;
for i = 0 to
#m "spritexy? playerfire" ; i ; " x
if x < -100 or x > winx + 100
or y < -100 or y > winy + 100
#m "spritemovexy playerfire" ; i ; " 0
end if
next i
#m "spritexy? ufo ufox
if ufox < -100
ufox = winx
ufohasfired = false
state = rnd( 0 ) * ( winx / 2 ) + winx / 4 -
end if
state = state -
if state < 0 and not( ufohasfired )
ufohasfired = true
dx = px -
dy = py -
af = sqr( dx ^ 2 + dy ^ 2 ) +
#m "spritexy ufofire " ; ufox ; " " ;
#m "spritemovexy ufofire " ; dx / af * 6 ; " " ; dy / af *
end if
#m "spritexy? ufofire x
if x < -100 then #m "spritemovexy ufofire 0
if x > winx then #m "spritemovexy ufofire 0
if y < -100 then #m "spritemovexy ufofire 0
if y > winy then #m "spritemovexy ufofire 0
#m "spritexy ufo " ; ufox ; " " ;
for i = 0 to
#m "spritexy? rock"; i ; " x
if x < -100 then x =
if x > winx then x =
if y < -100 then y =
if y > winy then y =
#m "spritexy rock" ; i ; " " ; x ; " " ;
next i
''colisiondetecion and
#m "spritecollides player
if instr( playerhit$ , "rock" ) <> 0
or instr( playerhit$ , "ufo" ) <> 0
lives = lives -
if lives < 0
call gameover
else
call resetscene
end if
end if
#m "spritecollides rock0
if instr( rockhit$ , "playerfire" )
and rockst( 0 ) = flies
point
call rocksplit 0 , 1 ,
end if
for i = 1 to
#m "spritecollides rock" ; i ; "
if instr( rockhit$ , "playerfire" )
and rockst( i ) = flies
point
if i = 1
call rocksplit 1 , 3 ,
else
call rocksplit 2 , 5 ,
end if
end if
next i
for i = 3 to
#m "spritecollides rock" ; i ; "
if instr( rockhit$ , "playerfire" )
and rockst( 0 ) = flies
point
rockst( i ) = washit
#m "spritexy rock" ; i ; " -100
#m "spritemove rock" ; i ; " 0
end if
next i
#m "spritecollides ufo
if instr( ufohit$ , "playerfire" )
points
#m "spritexy ufo " ; winx ; " "
; rnd( 0 ) * ( winy / 2 ) + winy / 4 -
state = rnd( 0 ) * ( winx / 2 ) + winx /
ufohasfired = false
call drawpoints
end if
for i = 0 to
#m "spritexy? star" ; i ; " x
if y > winy
#m "spritexy star" ; i ; " " ; rnd( 0 ) * winx ; " " ;
#m "spritescale star" ; i ; " "
; rnd( 0 ) ^ 3 *
end if
next i
allwashit = true
if ufost <> washit then allwashit =
for i = 0 to
if rock( i ) <> washit then allwashit =
next i
if allwashit then call
#m "drawsprites"
wait
sub resetgame
level = 0
lives = 3
points = 0
ufohasfired = false
state = rnd( 0 ) * ( winx / 2 ) + winx /
call resetscene
end sub
sub resetscene
timer 0
call drawpoints
for i = 1 to
#m "spritexy live" ; i ; " " ; i * 50 ; " " ; winy -
next i
for i = 0 to
#m "spritexy playerfire" ; i ; " -100
next i
#m "spritexy ufofire -100
px = winx /
py = winy /
#m "spritexy player " ; px ; " " ;
timer 40 ,
end sub
sub nextlevel
for i = 0 to
rockst( i ) = notjetactif
next i
rockst( 0 ) = flies
#m "spritexy rock0 -100 " ; rnd( 0 ) * winy -
#m "spritemovexy rock0 " ; x ; " " ;
ufost = flies
level
state = rnd( 0 ) * winx / 2 + winx / 2 -
#m "spritexy ufo " ; winx ; " " ; rnd(0) * winy/2 + winy/4 -
call resetscene
end sub
sub gameover
notice chr$( 13 )
+ "GAME OVER
goto [quit]
end sub
sub rocksplit no , a ,
dx = rockdx( no
dy = rockdy( no
rockst( no ) =
#m "spritexy? rock" ; no ; " x
#m "spritexy rock" ; no ; " -100
#m "spritemovexy rock" ; no ; " 0
#m "spritexy rock" ; a ; " " ; x ; " " ;
rockst( a ) =
call rotate dx , dy ,
#m "spritemove rock" ; a ; " " ; dx ; " " ;
#m "spritexy rock" ; b ; " " ; x ; " " ;
rockst( b ) =
call rotate dx , dy ,
#m "spritemove rock" ; b ; " " ; dx ; " " ;
end sub
sub rotate byref k , byref l ,
s = sin( deg * pi / 180
c = cos( deg * pi / 180
hk = k * c - l *
hl = l * s + l *
k = hk : l =
end sub
sub drawpoints
#m "fill
#m "font Corier_New 50
#m "color
#m "backcolor
#m "goto 0
#m "\POINTS : " ; right$( " " + str$( points ) , 8
#m "goto 200
#m "\LEVEL : " ;
#m "getbmp back 0 0 " ; winx ; " " ;
#m "background
for i = 0 to
#m "spritexy live" ; i ; " " ; i * 50 ; " " ;
next i
for i = lives to
#m "spritexy live" ; i ; " -100
next i
end sub
function strad( st
strad = st * pi /
end function
[key]
lastkey$ = right$( Inkey$ , 1
wait
[quit]
unloadbmp "fire"
unloadbmp "ufo"
unloadbmp "star"
for i = 0 to
unloadbmp "p" ;
next i
close #m
end