Skip to main content
guest
Join
|
Help
|
Sign In
Liberty BASIC Community Wiki
Home
guest
|
Join
|
Help
|
Sign In
Wiki Home
Recent Changes
Pages and Files
Members
Home
Liberty BASIC FAQ
Contests
Tutorials
Science
Shared Code
Tips
DLLs
PublicDomainSprites
Member Pages
Links
Sandbox
asteriods 2
Edit
0
7
…
0
Tags
No tags
Notify
RSS
Backlinks
Source
Print
Export (PDF)
Older Version
Newer Version
bluatigro
Jul 23, 2010
Highlight Changes
(
Deleted
,
Inserted
)
View WikiText
''version 23 jul 2010
''gordons Joy1x fix put into this to
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
global winx , winy
winx = WindowWidth
winy = WindowHeight
global px , py , pst , lastkey$ , pi , q , d , joyYN$ , firetel
global points , lives , state , ufohasfired , level , ufost
global true , false
global sndPlayerFire$ , sndPlayerWasHit$ , sndRockWasHit$
global sndUfoWasHit$ , sndUfoFlie$
global notjetactif , flies , washit
notjetactif = 0
flies = 1
washit = 2
global rockmax , ufomax
dim rockdx( 8 ) , rockdy( 8 ) , rockst( 8 )
false = 0
true = not( false )
pi = atn( 1 ) * 4
level = 0
for i = 0 to 31
loadbmp "p";i , DefaultDir$ + "\BMP\player" + nr$( i ) + ".bmp"
anim$ = anim$ + " p";i
next i
loadbmp "fire" , DefaultDir$ + "\BMP\dot.bmp"
loadbmp "rock" , DefaultDir$ + "\BMP\rock.bmp"
loadbmp "ufo" , DefaultDir$ + "\BMP\ufo.bmp"
loadbmp "star" , DefaultDir$ + "\BMP\star.bmp"
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 then
confirm chr$( 13 ) _
+ "Joystick detected . " + chr$( 13 ) _
+ "Use joystick ?" ; joyYN$
end if
''graphicbox #m.g , 0 , 0 , winx , winy
nomainwin
open "asteriods" for graphics as #m
#m "trapclose [quit]"
#m "when characterInput [key]"
#m "fill black"
#m "backcolor white"
#m "color white"
#m "getbmp back 0 0 " ; winx ; " " ; winy
#m "background back"
for i = 0 to 100
#m "addsprite star" ; i ; " star"
#m "spritexy star"; i ; " " _
; rnd( 0 ) * winx ; " " ; rnd( 0 ) * winy
#m "spritescale star"; i ; " " ; rnd( 0 ) ^ 3 * 100
#m "spritemovexy star" ; i ; " 0 1"
next i
for i = 0 to 4
#m "addsprite live" ; i ; " p" ; 0
#m "spritexy live" ; i ; " " ; i * 50 ; " " ; winy - 50
#m "spritescale live"; i ; " 50"
next i
for i = 0 to 20
#m "addsprite playerfire" ; i ; " fire"
#m "spritexy playerfire" ; i ; " -100 -100"
next i
for i = 0 to 7
#m "addsprite rock" ; i ; " rock"
next i
#m "spritescale rock0 100"
#m "spritescale rock1 70"
#m "spritescale rock2 70"
#m "spritescale rock3 50"
#m "spritescale rock4 50"
#m "spritescale rock5 50"
#m "spritescale rock6 50"
#m "addsprite ufo ufo"
#m "addsprite ufofire fire"
#m "setfocus"
#m "addsprite player " ; anim$
#m "spritexy player " ; px ; " " ; py
call resetgame
call nextlevel
call drawpoints
timer 40 , [tmr]
wait
function nr$( no )
nr$ = right$( "00" + str$( no ) , 2 )
end function
[tmr]
q = q - 1
if q < 0 then
q = int( rnd( 0 ) * 20 )
d = int( rnd( 0 ) * 3 )
end if
if JoyYN$ = "yes" then
if Joy1x < 256 * 256 / 3 then
pst = ( pst + 1 )
if pst > 31 then pst = 0
end if
if Joy1x > 256 * 256 * 2 / 3 then
pst = ( pst - 1 )
if pst < 0 then pst = 31
end if
if Joy1y < 256 * 256 / 3 then
px = ( px - sin( strad( pst ) ) * 5 )
if px < -100 then px = winx
if px > winx then px = -100
py = ( py - cos( strad( pst ) ) * 5 )
if py < -100 then py = winy
if py > winy then py = -100
end if
if Joy1y > 256 * 256 * 2 / 3 then
''here i wil place a hyperjump in the furture
end if
else
select case lower$( lastkey$ )
case chr$( _VK_LEFT )
pst = ( pst + 1 )
if pst > 32 then pst = 0
case chr$( _VK_RIGHT )
pst = ( pst - 1 )
if pst < 0 then pst = 32
case chr$( _VK_UP )
px = ( px - sin( strad( pst ) ) * 5 )
if px < -100 then px = winx
if px > winx then px = -100
py = ( py - cos( strad( pst ) ) * 5 )
if py < -100 then py = winy
if py > winy then py = -100
case chr$( _VK_DOWN )
''hyperjump
case chr$( 27 ) ''escape
goto [quit]
wait
case " "
#m "spritexy playerfire" ; firetel ; " " _
; px - 16 - sin( strad( pst ) ) * 45 ; " " _
; py - 16 - cos( strad( pst ) ) * 45
#m "spritemovexy playerfire" ; firetel ; " " _
; sin( strad( pst ) ) * -6 ; " " _
; cos( strad( pst ) ) * -6
firetel = firetel + 1
if firetel > 20 then firetel = 0
end select
end if
lastkey$ = ""
#m "spritexy player " ; px - 50 ; " " ; py - 50
#m "spriteimage player p" ; pst
for i = 0 to 10
#m "spritexy? playerfire" ; i ; " x y"
if x < -100 or x > winx + 100 _
or y < -100 or y > winy + 100 then
#m "spritemovexy playerfire" ; i ; " 0 0"
end if
next i
#m "spritexy? ufo ufox ufoy"
if ufox < -100 then
ufox = winx
ufohasfired = false
state = rnd( 0 ) * ( winx / 2 ) + winx / 4 - 35
end if
state = state - 1
if state < 0 and not( ufohasfired ) then
ufohasfired = true
dx = px - ufox
dy = py - ufoy
af = sqr( dx ^ 2 + dy ^ 2 ) + 1
#m "spritexy ufofire " ; ufox ; " " ; ufoy
#m "spritemovexy ufofire " ; dx / af * 6 ; " " ; dy / af * 6
end if
#m "spritexy? ufofire x y"
if x < -100 then #m "spritemovexy ufofire 0 0"
if x > winx then #m "spritemovexy ufofire 0 0"
if y < -100 then #m "spritemovexy ufofire 0 0"
if y > winy then #m "spritemovexy ufofire 0 0"
#m "spritexy ufo " ; ufox ; " " ; ufoy
for i = 0 to 6
#m "spritexy? rock"; i ; " x y"
if x < -100 then x = winx
if x > winx then x = -100
if y < -100 then y = winy
if y > winy then y = -100
#m "spritexy rock" ; i ; " " ; x ; " " ; y
next i
''colisiondetecion and respons
#m "spritecollides player playerhit$"
if instr( playerhit$ , "rock" ) <> 0 _
or instr( playerhit$ , "ufo" ) <> 0 then
lives = lives - 1
if lives < 0 then
goto [gameover]
wait
else
call resetscene
end if
end if
#m "spritecollides rock0 rockhit$"
if instr( rockhit$ , "playerfire" ) _
and rockst( 0 ) = flies then
call removefire
points = points + 1
call drawpoints
call rocksplit 0 , 1 , 2
end if
for i = 1 to 2
#m "spritecollides rock" ; i ; " rockhit$"
if instr( rockhit$ , "playerfire" ) _
and rockst( i ) = flies then
call removefire
points = points + 2
call drawpoints
if i = 1 then
call rocksplit 1 , 3 , 4
else
call rocksplit 2 , 5 , 6
end if
end if
next i
for i = 3 to 6
#m "spritecollides rock" ; i ; " rockhit$"
if instr( rockhit$ , "playerfire" ) _
and rockst( i ) = flies then
call removefire
points = points + 4
call drawpoints
rockst( i ) = washit
#m "spritexy rock" ; i ; " -100 -100"
#m "spritemovexy rock" ; i ; " 0 0"
end if
next i
#m "spritecollides ufo ufohit$"
if instr( ufohit$ , "playerfire" ) then
points = points + 7
#m "spritexy ufo " ; winx ; " " _
; rnd( 0 ) * ( winy / 2 ) + winy / 4 - 50
state = rnd( 0 ) * ( winx / 2 ) + winx / 4
ufohasfired = false
call drawpoints
end if
for i = 0 to 100
#m "spritexy? star" ; i ; " x y"
if y > winy then
#m "spritexy star" ; i ; " " ; rnd( 0 ) * winx ; " " ; -30
#m "spritescale star" ; i ; " " _
; rnd( 0 ) ^ 3 * 100
end if
next i
allwashit = true
if ufost <> washit then allwashit = false
for i = 0 to 6
if rock( i ) <> washit then allwashit = false
next i
if allwashit then call nextlevel
#m "drawsprites"
wait
sub removefire
for i = 0 to 20
#m "spritexy playerfire" ; i ; " -100 -100"
#m "spritemovexy playerfire" ; i ; " 0 0"
next i
end sub
sub resetgame
level = 0
lives = 3
points = 0
ufohasfired = false
state = rnd( 0 ) * ( winx / 2 ) + winx / 4
call resetscene
end sub
sub resetscene
timer 0
call drawpoints
for i = 1 to 4
#m "spritexy live" ; i ; " " ; i * 50 ; " " ; winy - 50
next i
for i = 0 to 20
#m "spritexy playerfire" ; i ; " -100 -100"
next i
#m "spritexy ufofire -100 -100"
px = winx / 2
py = winy / 2
#m "spritexy player " ; px ; " " ; py
timer 40 , [tmr]
end sub
sub nextlevel
for i = 0 to 7
rockst( i ) = notjetactif
#m "spritexy rock" ; i ; " -100 -100"
#m "spritemovexy rock" ; i ; " 0 0"
next i
rockst( 0 ) = flies
#m "spritexy rock0 -100 " ; rnd( 0 ) * winy - 50
x = 0 : y = 0
while abs( x ) = 0 or abs( y ) = 0
x = int( rnd( 0 ) * 7 - 3 )
y = int( rnd( 0 ) * 7 - 3 )
wend
#m "spritemovexy rock0 " ; x ; " " ; y
ufost = flies
level = level + 1
state = rnd( 0 ) * winx / 2 + winx / 2 - 50
#m "spritexy ufo " ; winx ; " " ; rnd(0) * winy/2 + winy/4 - 35
call resetscene
end sub
sub rocksplit no , a , b
dx = rockdx( no )
dy = rockdy( no )
rockst( no ) = washit
#m "spritexy? rock" ; no ; " x y"
#m "spritexy rock" ; no ; " -100 -100"
#m "spritemovexy rock" ; no ; " 0 0"
#m "spritexy rock" ; a ; " " ; x ; " " ; y
rockst( a ) = flies
'' call rotate dx , dy , 120
dx = 0 : dy = 0
while dx = 0 or dy = 0
dx = int( rnd( 0 ) * 5 - 2 )
dy = int( rnd( 0 ) * 5 - 2 )
wend
rockdx( a ) = dx : rockdy( a ) = dy
#m "spritemovexy rock" ; a ; " " ; dx ; " " ; dy
#m "spritexy rock" ; b ; " " ; x ; " " ; y
rockst( b ) = flies
'' call rotate dx , dy , 120
dx = 0 : dy = 0
while dx = 0 or dy = 0
dx = int( rnd( 0 ) * 5 - 2 )
dy = int( rnd( 0 ) * 5 - 2 )
wend
rockdx( b ) = dx : rockdy( b ) = dy
#m "spritemovexy rock" ; b ; " " ; dx ; " " ; dy
end sub
sub rotate byref k , byref l , deg
s = sin( deg * pi / 180 )
c = cos( deg * pi / 180 )
hk = k * c - l * s
hl = l * s + l * c
k = hk : l = lh
end sub
sub drawpoints
#m "fill black"
#m "font Corier_New 50 bold"
#m "color green"
#m "backcolor black"
#m "goto 0 50"
#m "\POINTS : " ; right$( " " + str$( points ) , 8 )
#m "goto 0 " ; winy - 100
#m "\LEVEL : " ; level
#m "getbmp back 0 0 " ; winx ; " " ; winy
#m "background back"
for i = 0 to lives
#m "spritexy live" ; i ; " " ; i * 50 ; " " ; 50
next i
for i = lives to 3
#m "spritexy live" ; i ; " -100 -100"
next i
end sub
function strad( st )
strad = st * pi / 16
end function
[key]
lastkey$ = right$( Inkey$ , 1 )
wait
[gameover]
notice chr$( 13 ) _
+ "points : " + str$( points ) + chr$( 13 ) _
+ "GAME OVER !!!"
[quit]
unloadbmp "fire"
unloadbmp "ufo"
unloadbmp "star"
unloadbmp "rock"
for i = 0 to 31
unloadbmp "p" ; i
next i
close #m
end
Turn off "Getting Started"
Home
...
Loading...
''gordons Joy1x fix put into this to
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
global winx , winy
winx = WindowWidth
winy = WindowHeight
global px , py , pst , lastkey$ , pi , q , d , joyYN$ , firetel
global points , lives , state , ufohasfired , level , ufost
global true , false
global sndPlayerFire$ , sndPlayerWasHit$ , sndRockWasHit$
global sndUfoWasHit$ , sndUfoFlie$
global notjetactif , flies , washit
notjetactif = 0
flies = 1
washit = 2
global rockmax , ufomax
dim rockdx( 8 ) , rockdy( 8 ) , rockst( 8 )
false = 0
true = not( false )
pi = atn( 1 ) * 4
level = 0
for i = 0 to 31
loadbmp "p";i , DefaultDir$ + "\BMP\player" + nr$( i ) + ".bmp"
anim$ = anim$ + " p";i
next i
loadbmp "fire" , DefaultDir$ + "\BMP\dot.bmp"
loadbmp "rock" , DefaultDir$ + "\BMP\rock.bmp"
loadbmp "ufo" , DefaultDir$ + "\BMP\ufo.bmp"
loadbmp "star" , DefaultDir$ + "\BMP\star.bmp"
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 then
confirm chr$( 13 ) _
+ "Joystick detected . " + chr$( 13 ) _
+ "Use joystick ?" ; joyYN$
end if
''graphicbox #m.g , 0 , 0 , winx , winy
nomainwin
open "asteriods" for graphics as #m
#m "trapclose [quit]"
#m "when characterInput [key]"
#m "fill black"
#m "backcolor white"
#m "color white"
#m "getbmp back 0 0 " ; winx ; " " ; winy
#m "background back"
for i = 0 to 100
#m "addsprite star" ; i ; " star"
#m "spritexy star"; i ; " " _
; rnd( 0 ) * winx ; " " ; rnd( 0 ) * winy
#m "spritescale star"; i ; " " ; rnd( 0 ) ^ 3 * 100
#m "spritemovexy star" ; i ; " 0 1"
next i
for i = 0 to 4
#m "addsprite live" ; i ; " p" ; 0
#m "spritexy live" ; i ; " " ; i * 50 ; " " ; winy - 50
#m "spritescale live"; i ; " 50"
next i
for i = 0 to 20
#m "addsprite playerfire" ; i ; " fire"
#m "spritexy playerfire" ; i ; " -100 -100"
next i
for i = 0 to 7
#m "addsprite rock" ; i ; " rock"
next i
#m "spritescale rock0 100"
#m "spritescale rock1 70"
#m "spritescale rock2 70"
#m "spritescale rock3 50"
#m "spritescale rock4 50"
#m "spritescale rock5 50"
#m "spritescale rock6 50"
#m "addsprite ufo ufo"
#m "addsprite ufofire fire"
#m "setfocus"
#m "addsprite player " ; anim$
#m "spritexy player " ; px ; " " ; py
call resetgame
call nextlevel
call drawpoints
timer 40 , [tmr]
wait
function nr$( no )
nr$ = right$( "00" + str$( no ) , 2 )
end function
[tmr]
q = q - 1
if q < 0 then
q = int( rnd( 0 ) * 20 )
d = int( rnd( 0 ) * 3 )
end if
if JoyYN$ = "yes" then
if Joy1x < 256 * 256 / 3 then
pst = ( pst + 1 )
if pst > 31 then pst = 0
end if
if Joy1x > 256 * 256 * 2 / 3 then
pst = ( pst - 1 )
if pst < 0 then pst = 31
end if
if Joy1y < 256 * 256 / 3 then
px = ( px - sin( strad( pst ) ) * 5 )
if px < -100 then px = winx
if px > winx then px = -100
py = ( py - cos( strad( pst ) ) * 5 )
if py < -100 then py = winy
if py > winy then py = -100
end if
if Joy1y > 256 * 256 * 2 / 3 then
''here i wil place a hyperjump in the furture
end if
else
select case lower$( lastkey$ )
case chr$( _VK_LEFT )
pst = ( pst + 1 )
if pst > 32 then pst = 0
case chr$( _VK_RIGHT )
pst = ( pst - 1 )
if pst < 0 then pst = 32
case chr$( _VK_UP )
px = ( px - sin( strad( pst ) ) * 5 )
if px < -100 then px = winx
if px > winx then px = -100
py = ( py - cos( strad( pst ) ) * 5 )
if py < -100 then py = winy
if py > winy then py = -100
case chr$( _VK_DOWN )
''hyperjump
case chr$( 27 ) ''escape
goto [quit]
wait
case " "
#m "spritexy playerfire" ; firetel ; " " _
; px - 16 - sin( strad( pst ) ) * 45 ; " " _
; py - 16 - cos( strad( pst ) ) * 45
#m "spritemovexy playerfire" ; firetel ; " " _
; sin( strad( pst ) ) * -6 ; " " _
; cos( strad( pst ) ) * -6
firetel = firetel + 1
if firetel > 20 then firetel = 0
end select
end if
lastkey$ = ""
#m "spritexy player " ; px - 50 ; " " ; py - 50
#m "spriteimage player p" ; pst
for i = 0 to 10
#m "spritexy? playerfire" ; i ; " x y"
if x < -100 or x > winx + 100 _
or y < -100 or y > winy + 100 then
#m "spritemovexy playerfire" ; i ; " 0 0"
end if
next i
#m "spritexy? ufo ufox ufoy"
if ufox < -100 then
ufox = winx
ufohasfired = false
state = rnd( 0 ) * ( winx / 2 ) + winx / 4 - 35
end if
state = state - 1
if state < 0 and not( ufohasfired ) then
ufohasfired = true
dx = px - ufox
dy = py - ufoy
af = sqr( dx ^ 2 + dy ^ 2 ) + 1
#m "spritexy ufofire " ; ufox ; " " ; ufoy
#m "spritemovexy ufofire " ; dx / af * 6 ; " " ; dy / af * 6
end if
#m "spritexy? ufofire x y"
if x < -100 then #m "spritemovexy ufofire 0 0"
if x > winx then #m "spritemovexy ufofire 0 0"
if y < -100 then #m "spritemovexy ufofire 0 0"
if y > winy then #m "spritemovexy ufofire 0 0"
#m "spritexy ufo " ; ufox ; " " ; ufoy
for i = 0 to 6
#m "spritexy? rock"; i ; " x y"
if x < -100 then x = winx
if x > winx then x = -100
if y < -100 then y = winy
if y > winy then y = -100
#m "spritexy rock" ; i ; " " ; x ; " " ; y
next i
''colisiondetecion and respons
#m "spritecollides player playerhit$"
if instr( playerhit$ , "rock" ) <> 0 _
or instr( playerhit$ , "ufo" ) <> 0 then
lives = lives - 1
if lives < 0 then
goto [gameover]
wait
else
call resetscene
end if
end if
#m "spritecollides rock0 rockhit$"
if instr( rockhit$ , "playerfire" ) _
and rockst( 0 ) = flies then
call removefire
points = points + 1
call drawpoints
call rocksplit 0 , 1 , 2
end if
for i = 1 to 2
#m "spritecollides rock" ; i ; " rockhit$"
if instr( rockhit$ , "playerfire" ) _
and rockst( i ) = flies then
call removefire
points = points + 2
call drawpoints
if i = 1 then
call rocksplit 1 , 3 , 4
else
call rocksplit 2 , 5 , 6
end if
end if
next i
for i = 3 to 6
#m "spritecollides rock" ; i ; " rockhit$"
if instr( rockhit$ , "playerfire" ) _
and rockst( i ) = flies then
call removefire
points = points + 4
call drawpoints
rockst( i ) = washit
#m "spritexy rock" ; i ; " -100 -100"
#m "spritemovexy rock" ; i ; " 0 0"
end if
next i
#m "spritecollides ufo ufohit$"
if instr( ufohit$ , "playerfire" ) then
points = points + 7
#m "spritexy ufo " ; winx ; " " _
; rnd( 0 ) * ( winy / 2 ) + winy / 4 - 50
state = rnd( 0 ) * ( winx / 2 ) + winx / 4
ufohasfired = false
call drawpoints
end if
for i = 0 to 100
#m "spritexy? star" ; i ; " x y"
if y > winy then
#m "spritexy star" ; i ; " " ; rnd( 0 ) * winx ; " " ; -30
#m "spritescale star" ; i ; " " _
; rnd( 0 ) ^ 3 * 100
end if
next i
allwashit = true
if ufost <> washit then allwashit = false
for i = 0 to 6
if rock( i ) <> washit then allwashit = false
next i
if allwashit then call nextlevel
#m "drawsprites"
wait
sub removefire
for i = 0 to 20
#m "spritexy playerfire" ; i ; " -100 -100"
#m "spritemovexy playerfire" ; i ; " 0 0"
next i
end sub
sub resetgame
level = 0
lives = 3
points = 0
ufohasfired = false
state = rnd( 0 ) * ( winx / 2 ) + winx / 4
call resetscene
end sub
sub resetscene
timer 0
call drawpoints
for i = 1 to 4
#m "spritexy live" ; i ; " " ; i * 50 ; " " ; winy - 50
next i
for i = 0 to 20
#m "spritexy playerfire" ; i ; " -100 -100"
next i
#m "spritexy ufofire -100 -100"
px = winx / 2
py = winy / 2
#m "spritexy player " ; px ; " " ; py
timer 40 , [tmr]
end sub
sub nextlevel
for i = 0 to 7
rockst( i ) = notjetactif
#m "spritexy rock" ; i ; " -100 -100"
#m "spritemovexy rock" ; i ; " 0 0"
next i
rockst( 0 ) = flies
#m "spritexy rock0 -100 " ; rnd( 0 ) * winy - 50
x = 0 : y = 0
while abs( x ) = 0 or abs( y ) = 0
x = int( rnd( 0 ) * 7 - 3 )
y = int( rnd( 0 ) * 7 - 3 )
wend
#m "spritemovexy rock0 " ; x ; " " ; y
ufost = flies
level = level + 1
state = rnd( 0 ) * winx / 2 + winx / 2 - 50
#m "spritexy ufo " ; winx ; " " ; rnd(0) * winy/2 + winy/4 - 35
call resetscene
end sub
sub rocksplit no , a , b
dx = rockdx( no )
dy = rockdy( no )
rockst( no ) = washit
#m "spritexy? rock" ; no ; " x y"
#m "spritexy rock" ; no ; " -100 -100"
#m "spritemovexy rock" ; no ; " 0 0"
#m "spritexy rock" ; a ; " " ; x ; " " ; y
rockst( a ) = flies
'' call rotate dx , dy , 120
dx = 0 : dy = 0
while dx = 0 or dy = 0
dx = int( rnd( 0 ) * 5 - 2 )
dy = int( rnd( 0 ) * 5 - 2 )
wend
rockdx( a ) = dx : rockdy( a ) = dy
#m "spritemovexy rock" ; a ; " " ; dx ; " " ; dy
#m "spritexy rock" ; b ; " " ; x ; " " ; y
rockst( b ) = flies
'' call rotate dx , dy , 120
dx = 0 : dy = 0
while dx = 0 or dy = 0
dx = int( rnd( 0 ) * 5 - 2 )
dy = int( rnd( 0 ) * 5 - 2 )
wend
rockdx( b ) = dx : rockdy( b ) = dy
#m "spritemovexy rock" ; b ; " " ; dx ; " " ; dy
end sub
sub rotate byref k , byref l , deg
s = sin( deg * pi / 180 )
c = cos( deg * pi / 180 )
hk = k * c - l * s
hl = l * s + l * c
k = hk : l = lh
end sub
sub drawpoints
#m "fill black"
#m "font Corier_New 50 bold"
#m "color green"
#m "backcolor black"
#m "goto 0 50"
#m "\POINTS : " ; right$( " " + str$( points ) , 8 )
#m "goto 0 " ; winy - 100
#m "\LEVEL : " ; level
#m "getbmp back 0 0 " ; winx ; " " ; winy
#m "background back"
for i = 0 to lives
#m "spritexy live" ; i ; " " ; i * 50 ; " " ; 50
next i
for i = lives to 3
#m "spritexy live" ; i ; " -100 -100"
next i
end sub
function strad( st )
strad = st * pi / 16
end function
[key]
lastkey$ = right$( Inkey$ , 1 )
wait
[gameover]
notice chr$( 13 ) _
+ "points : " + str$( points ) + chr$( 13 ) _
+ "GAME OVER !!!"
[quit]
unloadbmp "fire"
unloadbmp "ufo"
unloadbmp "star"
unloadbmp "rock"
for i = 0 to 31
unloadbmp "p" ; i
next i
close #m
end