InitSprite()
InitKeyboard()
InitSound()
OpenScreen(800,600,16,"Spiel")
Global beginn.w
Global box.w
Global Heli1X.w
Global Heli1Y.w
Global Heli2X.w
Global Heli2Y.w
Global Kugel1startY.w
Global Kugel2startY.w
Global Heli1Leben.d
Global Heli2Leben.d
Global KugelSpeed = 6
Global RaketeSpeed = 5
Global Rakete1 = 15
Global Rakete2 = 15
Heli1Leben = 100
Heli2Leben = 100
Heli1X = 650
Heli1Y = 300
Heli2X = 250
Heli2Y = 300
boxX = 98
boxY = 48
LoadSound(0,"Sound\schuss.wav")
LoadSound(1,"Sound\fest.wav")
LoadSound(2,"Sound\hit.wav")
LoadSound(3,"Sound\rakete.wav")
LoadSound(4,"Sound\explode.wav")
LoadSprite(0,"Grafik\back.bmp")
LoadSprite(2,"Grafik\heli1_1.bmp")
LoadSprite(4,"Grafik\kugel1.bmp")
LoadSprite(3,"Grafik\heli2_1.bmp")
LoadSprite(6,"Grafik\start.bmp")
LoadSprite(8,"Grafik\rakete1.bmp")
LoadSprite(9,"Grafik\rakete2.bmp")
LoadSprite(10,"Grafik\explosion.bmp")
For anim = 1 To 14
LoadSprite(50 + anim,"Grafik\anim\Explosion" + Str(anim) +".bmp")
TransparentSpriteColor(50 + anim,RGB(255,0,255))
Next
anim = 1
For q = 1 To 6
LoadSprite(30 + q,"Grafik\Heli1_" + Str(q) + ".bmp")
LoadSprite(36 + q,"Grafik\Heli2_" + Str(q) + ".bmp")
TransparentSpriteColor(30 + q,RGB(255,0,255))
TransparentSpriteColor(36 + q,RGB(255,0,255))
Next
For x = 1 To 12
LoadSprite(200 + x,"Grafik\maps\collision" + Str(x) +".bmp")
TransparentSpriteColor(200 + x,RGB(255,0,255))
Next
For k = 1 To 12
LoadSprite(250 + k,"Grafik\maps\collisionklein" + Str(k) +".bmp")
TransparentSpriteColor(250 + k,RGB(255,0,255))
Next
TransparentSpriteColor(2,RGB(255,0,255))
TransparentSpriteColor(3,RGB(255,0,255))
TransparentSpriteColor(4,RGB(255,0,255))
TransparentSpriteColor(8,RGB(255,0,255))
TransparentSpriteColor(9,RGB(255,0,255))
TransparentSpriteColor(10,RGB(255,0,255))
Anfang:
anfang = 0
Repeat
ExamineKeyboard()
;{ Auswahl
If anfang = 0
DisplaySprite(6,0,0)
StartDrawing(ScreenOutput())
Box(boxX,boxY,50,20,100)
;KarteDraw
DrawText(100,50,"Karte 1")
DrawText(200,50,"Karte 2")
DrawText(300,50,"Karte 3")
DrawText(400,50,"Karte 4")
DrawText(500,50,"Karte 5")
DrawText(600,50,"Karte 6")
DrawText(100,200,"Karte 7")
DrawText(200,200,"Karte 8")
DrawText(300,200,"Karte 9")
DrawText(400,200,"Karte10")
DrawText(500,200,"Karte11")
DrawText(600,200,"Karte12")
;Heli1Draw
DrawText(100,350,"Heli 1")
DrawText(200,350,"Heli 2")
DrawText(300,350,"Heli 3")
DrawText(400,350,"Heli 4")
DrawText(500,350,"Heli 5")
DrawText(600,350,"Heli 6")
;Heli2Draw
DrawText(100,500,"Heli 1")
DrawText(200,500,"Heli 2")
DrawText(300,500,"Heli 3")
DrawText(400,500,"Heli 4")
DrawText(500,500,"Heli 5")
DrawText(600,500,"Heli 6")
StopDrawing()
;Karte Sprites
DisplayTransparentSprite(251,100,100)
DisplayTransparentSprite(252,200,100)
DisplayTransparentSprite(253,300,100)
DisplayTransparentSprite(254,400,100)
DisplayTransparentSprite(255,500,100)
DisplayTransparentSprite(256,600,100)
DisplayTransparentSprite(257,100,250)
DisplayTransparentSprite(258,200,250)
DisplayTransparentSprite(259,300,250)
DisplayTransparentSprite(260,400,250)
DisplayTransparentSprite(261,500,250)
DisplayTransparentSprite(262,600,250)
;Heli 1 Sprites
DisplayTransparentSprite(31,100,400)
DisplayTransparentSprite(32,200,400)
DisplayTransparentSprite(33,300,400)
DisplayTransparentSprite(34,400,400)
DisplayTransparentSprite(35,500,400)
DisplayTransparentSprite(36,600,400)
;Heli 2 Sprites
DisplayTransparentSprite(37,100,550)
DisplayTransparentSprite(38,200,550)
DisplayTransparentSprite(39,300,550)
DisplayTransparentSprite(40,400,550)
DisplayTransparentSprite(41,500,550)
DisplayTransparentSprite(42,600,550)
;box Bewegung
If KeyboardReleased(#PB_Key_Right)
boxX + 100
EndIf
If KeyboardReleased(#PB_Key_Left)
boxX - 100
EndIf
If KeyboardReleased(#PB_Key_Up)
boxY - 150
EndIf
If KeyboardReleased(#PB_Key_Down)
boxY + 150
EndIf
If boxX > 597
boxX = 598
ElseIf boxX < 99
boxX = 98
EndIf
If boxY > 497
boxY = 498
boxY = 48
EndIf
Select boxX
Case 98
boxXwahl = 1;11
Case 198
boxXwahl = 2;12
Case 298
boxXwahl = 3;13
Case 398
boxXwahl = 4;14
Case 498
boxXwahl = 5;15
Case 598
boxXwahl = 6;16
EndSelect
EndIf
Select boxY
Case 48
boxYwahl = 1
Case 198
boxYwahl = 2
Case 348
boxYwahl = 3
Case 498
boxYwahl = 4
EndSelect
;Kollisionwahl
If boxYwahl = 1 And boxXwahl = 1 And KeyboardReleased(#PB_Key_Return)
collisionwahl = 201
EndIf
If boxYwahl = 1 And boxXwahl = 2 And KeyboardReleased(#PB_Key_Return)
collisionwahl = 202
EndIf
If boxYwahl = 1 And boxXwahl = 3 And KeyboardReleased(#PB_Key_Return)
collisionwahl = 203
EndIf
If boxYwahl = 1 And boxXwahl = 4 And KeyboardReleased(#PB_Key_Return)
collisionwahl = 204
EndIf
If boxYwahl = 1 And boxXwahl = 5 And KeyboardReleased(#PB_Key_Return)
collisionwahl = 205
EndIf
If boxYwahl = 1 And boxXwahl = 6 And KeyboardReleased(#PB_Key_Return)
collisionwahl = 206
EndIf
If boxYwahl = 2 And boxXwahl = 1 And KeyboardReleased(#PB_Key_Return)
collisionwahl = 207
EndIf
If boxYwahl = 2 And boxXwahl = 2 And KeyboardReleased(#PB_Key_Return)
collisionwahl = 208
EndIf
If boxYwahl = 2 And boxXwahl = 3 And KeyboardReleased(#PB_Key_Return)
collisionwahl = 209
EndIf
If boxYwahl = 2 And boxXwahl = 4 And KeyboardReleased(#PB_Key_Return)
collisionwahl = 210
EndIf
If boxYwahl = 2 And boxXwahl = 5 And KeyboardReleased(#PB_Key_Return)
collisionwahl = 211
EndIf
If boxYwahl = 2 And boxXwahl = 6 And KeyboardReleased(#PB_Key_Return)
collisionwahl = 212
EndIf
;Heli1Wahl
If boxYwahl = 3 And boxXwahl = 1 And KeyboardReleased(#PB_Key_Return)
heli1wahl = 31
EndIf
If boxYwahl = 3 And boxXwahl = 2 And KeyboardReleased(#PB_Key_Return)
heli1wahl = 32
EndIf
If boxYwahl = 3 And boxXwahl = 3 And KeyboardReleased(#PB_Key_Return)
heli1wahl = 33
EndIf
If boxYwahl = 3 And boxXwahl = 4 And KeyboardReleased(#PB_Key_Return)
heli1wahl = 34
EndIf
If boxYwahl = 3 And boxXwahl = 5 And KeyboardReleased(#PB_Key_Return)
heli1wahl = 35
EndIf
If boxYwahl = 3 And boxXwahl = 6 And KeyboardReleased(#PB_Key_Return)
heli1wahl = 36
EndIf
;Heli2Wahl
If boxYwahl = 4 And boxXwahl = 1 And KeyboardReleased(#PB_Key_Return)
heli2wahl = 37
EndIf
If boxYwahl = 4 And boxXwahl = 2 And KeyboardReleased(#PB_Key_Return)
heli2wahl = 38
EndIf
If boxYwahl = 4 And boxXwahl = 3 And KeyboardReleased(#PB_Key_Return)
heli2wahl = 39
EndIf
If boxYwahl = 4 And boxXwahl = 4 And KeyboardReleased(#PB_Key_Return)
heli2wahl = 40
EndIf
If boxYwahl = 4 And boxXwahl = 5 And KeyboardReleased(#PB_Key_Return)
heli2wahl = 41
EndIf
If boxYwahl = 4 And boxXwahl = 6 And KeyboardReleased(#PB_Key_Return)
heli2wahl = 42
EndIf
If collisionwahl > 0 And heli1wahl > 0 And heli2wahl > 0
allesklar = 1
EndIf
If KeyboardReleased(#PB_Key_Space) And allesklar = 1
anfang = 1
beginn = 1
EndIf
;} Ende
If beginn = 1
DisplaySprite(0,0,0)
DisplayTransparentSprite(collisionwahl,0,0)
DisplayTransparentSprite(heli1wahl,Heli1X,Heli1Y)
DisplayTransparentSprite(heli2wahl,Heli2X,Heli2Y)
;Bewegung 1
If KeyboardPushed(#PB_Key_Up)
Heli1Y - 2
EndIf
If KeyboardPushed(#PB_Key_Down)
Heli1Y + 2
EndIf
If KeyboardPushed(#PB_Key_Right)
Heli1X + 2
EndIf
If KeyboardPushed(#PB_Key_Left)
Heli1X - 2
EndIf
;Bewegung 2
If KeyboardPushed(#PB_Key_W)
Heli2Y - 2
EndIf
If KeyboardPushed(#PB_Key_S)
Heli2Y + 2
EndIf
If KeyboardPushed(#PB_Key_D)
Heli2X + 2
EndIf
If KeyboardPushed(#PB_Key_A)
Heli2X - 2
EndIf
;Kollisionen Heli1-Bildschirmrand
If Heli1X >735
Heli1X =735
EndIf
If Heli1Y <-10
Heli1Y =-10
EndIf
If Heli1Y >570
Heli1Y =570
EndIf
If Heli1X <0
Heli1X =0
EndIf
;Kollisionen Heli2-Bildschirmrand
If Heli2X >735
Heli2X =735
EndIf
If Heli2Y <-10
Heli2Y =-10
EndIf
If Heli2Y >570
Heli2Y =570
EndIf
If Heli2X <0
Heli2X =0
EndIf
;Kollision Heli1-Felsen
If SpritePixelCollision(collisionwahl,0,0,2,Heli1X,Heli1Y)
Heli1Leben - 0.05
EndIf
;Kollision Heli2-Felsen
If SpritePixelCollision(collisionwahl,0,0,3,Heli2X,Heli2Y)
Heli2Leben - 0.05
EndIf
;Kollision Kugel1-Heli2
If SpritePixelCollision(4,kugel1a,kugel1startY,3,Heli2X,Heli2Y)
PlaySound(2)
Heli2Leben - 20
kugel1a = -5
EndIf
;Kollision Kugel1b-Heli2
If SpritePixelCollision(4,kugel1b,kugel1startYb,3,Heli2X,Heli2Y)
PlaySound(2)
Heli2Leben - 20
kugel1b = -5
EndIf
;Kollision Rakete1-Heli2
If SpritePixelCollision(8,rakete1a,rakete1startY,3,Heli2X,Heli2Y)
PlaySound(4)
Heli2Leben - 50
rakete1a = -40
animmach2 = 1
EndIf
;Kollision Kugel2-Heli1
If SpritePixelCollision(4,kugel2a,kugel2startY,2,Heli1X,Heli1Y)
PlaySound(2)
Heli1Leben - 20
kugel2a = 800
EndIf
;Kollision Kugel2b-Heli1
If SpritePixelCollision(4,kugel2b,kugel2startYb,2,Heli1X,Heli1Y)
PlaySound(2)
Heli1Leben - 20
kugel2b = 800
EndIf
;Kollision Rakete2-Heli1
If SpritePixelCollision(9,rakete2a,rakete2startY,3,Heli1X,Heli1Y)
PlaySound(4)
Heli1Leben - 50
rakete2a = 840
animmach1 = 1
EndIf
;Kollision Kugel1 Felsen
If SpritePixelCollision(4,kugel1a,kugel1startY,collisionwahl,0,0)
PlaySound(1)
kugel1a = -5
EndIf
;Kollision Kugel1b Felsen
If SpritePixelCollision(4,kugel1b,kugel1startYb,collisionwahl,0,0)
PlaySound(1)
kugel1b = -5
EndIf
;Kollision Rakete1 Felsen
If SpritePixelCollision(8,rakete1a,rakete1startY,collisionwahl,0,0)
PlaySound(4)
rakete1a = -40
EndIf
;Kollision Kugel2 Felsen
If SpritePixelCollision(4,kugel2a,kugel2startY,collisionwahl,0,0)
PlaySound(1)
kugel2a = 800
EndIf
;Kollision Kugel2 Felsen
If SpritePixelCollision(4,kugel2b,kugel2startYb,collisionwahl,0,0)
PlaySound(1)
kugel2b = 800
EndIf
;Kollision Rakete2 Felsen
If SpritePixelCollision(9,rakete2a,rakete2startY,collisionwahl,0,0)
PlaySound(4)
rakete2a = 840
EndIf
;Schiessen 1 Schuss
If KeyboardPushed(#PB_Key_Return) = 0 And geschossen1 = 0
schuss = 0
EndIf
If KeyboardPushed(#PB_Key_Return) And schuss = 0 ;And kugel1schiessa = 0
PlaySound(0)
kugel1schiessa = 1
kugel1a = Heli1X
kugel1startY = Heli1Y + 10
schuss = 1
EndIf
If kugel1schiessa = 1
DisplayTransparentSprite(4,kugel1a,kugel1startY)
kugel1a - KugelSpeed
geschossen1 = 1
EndIf
If kugel1a < -5
kugel1a = -5
geschossen1 = 0
EndIf
;Schiessen 1 Schuss b
If KeyboardPushed(#PB_Key_Back) = 0 And geschossen1b = 0
schuss1b = 0
EndIf
If KeyboardPushed(#PB_Key_Back) And schuss1b = 0 ;And kugel1schiessa = 0
PlaySound(0)
kugel1schiessb = 1
kugel1b = Heli1X
kugel1startYb = Heli1Y + 10
schuss1b = 1
EndIf
If kugel1schiessb = 1
DisplayTransparentSprite(4,kugel1b,kugel1startYb)
kugel1b - KugelSpeed
geschossen1b = 1
EndIf
If kugel1b < -5
kugel1b = -5
geschossen1b = 0
EndIf
;Schiessen 1 Rakete
If KeyboardPushed(#PB_Key_P) = 0 And geschossenrakete1 = 0
schussrakete = 0
EndIf
If KeyboardPushed(#PB_Key_P) And schussrakete = 0 And Rakete1 > 0 ;And kugel1schiessa = 0
PlaySound(3)
rakete1schiessa = 1
rakete1a = Heli1X
rakete1startY = Heli1Y + 10
schussrakete = 1
Rakete1 - 1
EndIf
If rakete1schiessa = 1
DisplayTransparentSprite(8,rakete1a,rakete1startY)
rakete1a - RaketeSpeed
geschossenrakete1 = 1
EndIf
If rakete1a < -17
rakete1a = -40
geschossenrakete1 = 0
EndIf
;Schiessen 2 Schuss
If KeyboardPushed(#PB_Key_B) = 0 And geschossen2 = 0
schuss2 = 0
EndIf
If KeyboardPushed(#PB_Key_B) And schuss2 = 0 ;And kugel1schiessa = 0
PlaySound(0)
kugel2schiessa = 1
kugel2a = Heli2X + 35
kugel2startY = Heli2Y + 10
schuss2 = 1
EndIf
If kugel2schiessa = 1
DisplayTransparentSprite(4,kugel2a,kugel2startY)
kugel2a + KugelSpeed
geschossen2 = 1
EndIf
If kugel2a > 805
kugel2a = 805
geschossen2 = 0
EndIf
;Schiessen 2 Schuss b
If KeyboardPushed(#PB_Key_N) = 0 And geschossen2b = 0
schuss2b = 0
EndIf
If KeyboardPushed(#PB_Key_N) And schuss2b = 0 ;And kugel1schiessa = 0
PlaySound(0)
kugel2schiessb = 1
kugel2b = Heli2X + 35
kugel2startYb = Heli2Y + 10
schuss2b = 1
EndIf
If kugel2schiessb = 1
DisplayTransparentSprite(4,kugel2b,kugel2startYb)
kugel2b + KugelSpeed
geschossen2b = 1
EndIf
If kugel2b > 805
kugel2b = 805
geschossen2b = 0
EndIf
;Schiessen 2 Rakete
If KeyboardPushed(#PB_Key_Space) = 0 And geschossenrakete2 = 0
schussrakete2 = 0
EndIf
If KeyboardPushed(#PB_Key_Space) And schussrakete2 = 0 And Rakete2 > 0 ;And kugel1schiessa = 0
PlaySound(3)
rakete2schiessa = 1
rakete2a = Heli2X + 30
rakete2startY = Heli2Y + 10
schussrakete2 = 1
Rakete2 - 1
EndIf
If rakete2schiessa = 1
DisplayTransparentSprite(9,rakete2a,rakete2startY)
rakete2a + RaketeSpeed
geschossenrakete2 = 1
EndIf
If rakete2a > 815
rakete2a = 840
geschossenrakete2 = 0
EndIf
;Leben Heli 1
StartDrawing(ScreenOutput())
DrawText(50,10,"Leben Heli2 :" + Str(Heli2Leben),0,RGB(164,164,255))
DrawText(200,10,"Raketen 2:" + Str(Rakete2),0,RGB(164,164,255))
DrawText(700,10,"Raketen 1:" + Str(Rakete1),0,RGB(164,164,255))
;Leben Heli 2
DrawText(500,10,"Leben Heli1 :" + Str(Heli1Leben),0,RGB(164,164,255))
StopDrawing()
If Heli1Leben < 1
StartDrawing(ScreenOutput())
DrawText(400,300,"Sieg für Spieler 2!")
StopDrawing()
beginn = 0
EndIf
If Heli2Leben < 1
StartDrawing(ScreenOutput())
DrawText(400,300,"Sieg für Spieler 1!")
beginn = 0
StopDrawing()
EndIf
EndIf
If animmach1 = 1
anim + 1
If anim = 14
animmach1 = 0
anim = 1
EndIf
If anim = 1
anim + 1
EndIf
DisplayTransparentSprite(50 + anim,Heli1X + 30,Heli1Y + 10)
EndIf
If animmach2 = 1
anim + 1
If anim = 14
animmach2 = 0
anim = 1
EndIf
If anim = 1
anim + 1
EndIf
DisplayTransparentSprite(50 + anim,Heli2X + 25,Heli2Y + 10)
EndIf
FlipBuffers()
Until KeyboardPushed(1)