Code: Alles auswählen
;{-Inits
InitSprite()
InitKeyboard()
InitSound()
InitMouse()
UseJPEGImageDecoder()
UseOGGSoundDecoder()
;}-
;{-Variablen
Global shipX.w
Global scroll.w
Global shipY.w
Global p.w
Global durch.b
Global Level.w
scroll=0
zahl=0
zahl2=0
Level=4
shipX = 820
shipY=Random(560)
ship2act=0
shipY2=Random(560)
shipX2=1600
ship3act=0
shipY3=Random(560)
shipX3=2600
ship4act=0
shipY4=Random(560)
shipX4=3800
;}-
;{-Sounds
LoadSound(6,"gaover.ogg")
LoadSound(22,"select.ogg")
SoundFrequency(22,12050)
SoundVolume(22,40)
LoadSound(12,"wecker.ogg")
SoundFrequency(12,22050)
SoundVolume(12,80)
LoadSound(20,"tada.wav")
SoundVolume(20,75)
;}-
;{-Sprites
LoadSprite(9,"space.bmp",0)
TransparentSpriteColor(9,255,255,255)
LoadSprite(88,"auswahl1.bmp",0)
TransparentSpriteColor(88,0,0,0)
LoadSprite(99,"auswahl2.bmp",0)
TransparentSpriteColor(99,0,0,0)
;}-
OpenScreen(800, 600, 32, "Spaceship Attack")
Goto menu
game:
PlaySound(4, 1)
Repeat
ExamineKeyboard()
ExamineMouse()
ClearScreen(0, 0, 0)
DisplaySprite(1, scroll, 0)
DisplayTransparentSprite(0,MouseX()-43,MouseY()-25)
If KeyboardPushed(1)
e=1
EndIf
If MouseX()>shipX And MouseX()<shipX+20 And MouseY()>shipY And MouseY()<shipY+20
shipY=Random(560)
shipX = 820
p+10
PlaySound(5, 0)
EndIf
If MouseX()>shipX2 And MouseX()<shipX2+20 And MouseY()>shipY2 And MouseY()<shipY2+20
shipY2=Random(560)
shipX2=1600
p+10
PlaySound(5, 0)
EndIf
If MouseX()>shipX3 And MouseX()<shipX3+20 And MouseY()>shipY3 And MouseY()<shipY3+20
shipY3=Random(560)
shipX3=2600
p+10
PlaySound(5, 0)
EndIf
If MouseX()>shipX4 And MouseX()<shipX4+20 And MouseY()>shipY4 And MouseY()<shipY4+20
shipY4=Random(560)
shipX4=3800
p+10
PlaySound(5, 0)
EndIf
DisplayTransparentSprite(3, shipX2, shipY2)
DisplayTransparentSprite(3,shipX3,shipY3)
DisplayTransparentSprite(3,shipX4,shipY4)
DisplayTransparentSprite(3,shipX, shipY)
StartDrawing(ScreenOutput())
DrawingMode(1)
Locate(350, 0)
FrontColor(155, 10, 20)
DrawText("Punkte: "+Str(p))
Locate(398, 585)
FrontColor(40, 125, 10)
DrawText(Str(durch))
StopDrawing()
FlipBuffers()
shipX-Level
If (p/200)+1>Level
Level=Level+1
EndIf
If scroll=-596
scroll=0
Else
scroll-2
EndIf
If ship2act=1
shipX2-Level
EndIf
If ship3act=1
shipX3-Level
EndIf
If ship4act=1
shipX4-Level
EndIf
If p=100
ship2act=1
EndIf
If p=350
ship3act=1
EndIf
If p=560
ship4act=1
EndIf
If shipX<-32
durch+1
shipX=820
shipY=Random(560)
EndIf
If shipX2<-32
durch+1
shipX2=1600
shipY2=Random(560)
EndIf
If shipX3<-32
durch+1
shipX3=2600
shipY3=Random(560)
EndIf
If shipX4<-32
durch+1
shipX4=3800
shipY4=Random(560)
EndIf
Until e=1 Or durch=5
e=0
StopSound(4)
If CreateFile(0,"HI.bin")
WriteString(Str(p))
Else
End
EndIf
CloseFile(0)
FreeSound(4)
FreeSound(5)
FreeSprite(0)
FreeSprite(1)
FreeSprite(3)
scroll=0
Level=4
shipX=820
shipX2=1600
ship2act=0
ship3act=0
ship4act=0
shipX3=2600
shipX4=3800
durch=0
Goto gover
Ending:
CloseScreen()
End
menu:
ka=1
ausx=280
ausy=140
ausx1=420
ausy1=140
k=0
Repeat
ClearScreen(0,0,50)
DisplayTransparentSprite(9,130,1)
StartDrawing(ScreenOutput())
DrawingMode(1)
Locate(320, 150)
FrontColor(100, 0, 255)
DrawText("Neues Spiel")
Locate(323, 300)
DrawText("High Score")
Locate(325, 450)
DrawText("Beenden")
Locate(270, 583)
FrontColor(145, 0, 0)
DrawText("By Twelve Productions 2005.")
StopDrawing()
ExamineKeyboard()
If KeyboardPushed(#PB_Key_1)
PlaySound(22, 0)
k=1
ElseIf KeyboardPushed(#PB_Key_2)
PlaySound(22, 0)
k=2
ElseIf KeyboardPushed(#PB_Key_Escape)
k=3
PlaySound(22, 0)
EndIf
DisplayTransparentSprite(88, ausx, ausy)
DisplayTransparentSprite(99, ausx1, ausy1)
FlipBuffers()
If KeyboardPushed(#PB_Key_Down)
ka+1
If ka=4
ka=1
ausy=140
ausy1=140
Else
ausy+150
ausy1+150
EndIf
PlaySound(22, 0)
EndIf
If KeyboardPushed(#PB_Key_Up)
ka-1
If ka=0
ka=3
ausy=440
ausy1=440
Else
ausy-150
ausy1-150
EndIf
PlaySound(22, 0)
EndIf
If KeyboardPushed(#PB_Key_Return)
k=ka
PlaySound(22, 0)
EndIf
Delay(100)
Until k=1 Or k=2 Or k=3
If k=1
Delay(400)
Goto loading
ElseIf k=2
Delay(400)
Goto highscore
ElseIf k=3
Delay(400)
Goto Ending
EndIf
highscore:
ClearScreen(0, 0, 50)
DisplayTransparentSprite(9, 130, 1)
StartDrawing(ScreenOutput())
FrontColor(100, 0, 255)
DrawingMode(1)
Locate(310, 300)
DrawText("Du hast beim letzten Mal")
If OpenFile(5, "HI.bin")
high$=ReadString()
CloseFile(5)
Locate(310, 320)
DrawText(high$+" Punkte erreicht!")
Else
Locate(310, 320)
DrawText("Fehler erreicht!")
EndIf
StopDrawing()
FlipBuffers()
e=0
PlaySound(20, 0)
Repeat
ExamineKeyboard()
If KeyboardPushed(1) Or KeyboardPushed(#PB_Key_Return)
e=1
EndIf
Until e=1
e=0
PlaySound(22, 0)
Delay(400)
Goto menu
loading:
ClearScreen(0, 0, 50)
DisplayTransparentSprite(9, 130, 1)
StartDrawing(ScreenOutput())
Locate(310, 300)
FrontColor(100, 0, 255)
ClearScreen(0,0,50)
Box(200, 300, 100, 30, RGB(0, 0, 255))
StopDrawing()
DisplayTransparentSprite(9, 130, 1)
FlipBuffers()
Delay(300)
LoadSound(4, "Music.ogg")
LoadSprite(0, "Eater1.bmp", 0)
ClearScreen(0, 0, 50)
SoundVolume(4, 45)
StartDrawing(ScreenOutput())
Box(200, 300, 200, 30, RGB(0, 0, 255))
StopDrawing()
DisplayTransparentSprite(9, 130, 1)
FlipBuffers()
Delay(500)
TransparentSpriteColor(0, 255, 255, 255)
LoadSprite(3,"ship1.bmp", #PB_Sprite_Texture)
TransparentSpriteColor(3, 255, 255, 255)
ClearScreen(0, 0, 50)
StartDrawing(ScreenOutput())
Box(200, 300, 300, 30, RGB(0, 0, 255))
StopDrawing()
DisplayTransparentSprite(9, 130, 1)
FlipBuffers()
Delay(400)
LoadSprite(1, "Background.jpg", 0)
LoadSound(5, "schluck.ogg")
ClearScreen(0,0,50)
StartDrawing(ScreenOutput())
Box(200,300,400,30, RGB(0,0,255))
StopDrawing()
DisplayTransparentSprite(9, 130, 1)
FlipBuffers()
For i=1 To 3
ClearScreen(0, 0, 50)
DisplayTransparentSprite(9, 130, 1)
StartDrawing(ScreenOutput())
DrawingMode(1)
Box(200, 300, 400, 30, RGB(0, 0, 255))
FrontColor(145, 0, 0)
Locate(398, 368)
DrawText(Str(i))
StopDrawing()
Delay(600)
FlipBuffers()
Next i
PlaySound(12, 0)
Delay(850)
Goto game
gover:
PlaySound(6, 0)
ClearScreen(0, 0, 50)
DisplayTransparentSprite(9, 130, 1)
StartDrawing(ScreenOutput())
Locate(340, 300)
FrontColor(100, 0, 255)
DrawingMode(1)
DrawText("Game Over!")
Locate(340, 320)
DrawText(Str(p)+" Punkte!")
StopDrawing()
FlipBuffers()
Delay(5000)
p=0
Goto menu