erstmals entschuldigung für den nicht gerade aussagekräftigen Titel, wusste keinen besseren.
Ich programmiere gerade ein Bomberman-Klon, bis jetzt hat auch alles ganz gut geklappt, habe nur ein kleines Problem.
Hier einmal der Code:
Code: Alles auswählen
InitSprite()
InitMouse()
InitKeyboard()
InitSound()
OpenScreen(1024,768,32,"Battle Bombers")
CreateSprite(0,60,60)
StartDrawing(SpriteOutput(0))
Box(0,0,60,60,#White)
StopDrawing()
CreateSprite(1,60,60)
StartDrawing(SpriteOutput(1))
Box(0,0,60,60,#Green)
StopDrawing()
CreateSprite(2,60,60)
StartDrawing(SpriteOutput(2))
Circle(30,30,30,#Yellow)
StopDrawing()
CreateSprite(3,60,60)
StartDrawing(SpriteOutput(3))
Box(0,0,60,60,#Red)
StopDrawing()
CreateSprite(4,60,60)
StartDrawing(SpriteOutput(4))
DrawingMode(1)
Box(0,0,60,60,#Gray)
DrawText( 10,25,"WALL",#White)
StopDrawing()
CreateSprite(5,60,60)
StartDrawing(SpriteOutput(5))
DrawingMode(1)
Box(0,0,60,60,#Green)
DrawText( 10,25,"D.Wall",#White)
StopDrawing()
CreateSprite(6,60,1)
StartDrawing(SpriteOutput(6))
DrawingMode(1)
Box(0,0,60,1,#Green)
StopDrawing()
CreateSprite(7,1,60)
StartDrawing(SpriteOutput(7))
DrawingMode(1)
Box(0,0,1,60,#Green)
StopDrawing()
Structure Explosion
Image.w
X.w
Y.w
Delay.w
EndStructure
Global NewList Expl.Explosion()
Procedure AddExpl(X,Y)
AddElement(Expl())
Expl()\X = X
Expl()\Y = Y
Expl()\Image = 3
Expl()\Delay = 10
EndProcedure
Structure Bombe
X.w
Y.w
Image.w
Starke.w
Delay.w
EndStructure
Global NewList Bombe.Bombe()
Procedure AddBombe(Image,X,Y,Starke)
AddElement(Bombe())
Bombe()\Image = Image
Bombe()\X = X
Bombe()\Y = Y
Bombe()\Starke = Starke
Bombe()\Delay = 200
EndProcedure
Structure Wall
X.w
Y.w
Image.w
Zerstorbar.w
Kill.w
EndStructure
Global NewList Wall.Wall()
Procedure AddWall(Image,X,Y,Zerstorbar)
AddElement(Wall())
Wall()\Image = Image
Wall()\X = X
Wall()\Y = Y
Wall()\Zerstorbar = Zerstorbar
EndProcedure
Procedure AddReihe(X,Y,S,D)
Protected a
If D = 1
For a = 0 To S*-60 Step -60
AddExpl(X,a+Y)
Next a
EndIf
If D = 2
For a = 0 To S*60 Step 60
AddExpl(a+X,Y)
Next a
EndIf
If D = 3
For a = 0 To S*60 Step 60
AddExpl(X,a+Y)
Next a
EndIf
If D = 4
For a = 0 To S*-60 Step -60
AddExpl(a+X,Y)
Next a
EndIf
EndProcedure
PlayerX = 0
PlayerY = 0
Delay = 30
Player2X = 60
Player2Y = 60
;-Testlevel
AddWall(5,120,0,1)
AddWall(4,60,60,0)
AddWall(5,0,120,1)
Repeat
FlipBuffers()
ExamineKeyboard()
ClearScreen(0)
StartDrawing(ScreenOutput())
DrawingMode(1)
DrawText(500,0,"PosX: "+Str(PlayerX),#White)
DrawText(500,15,"PosY: "+Str(PlayerY),#White)
DrawText(500,30,"Moving: "+Str(Moving),#White)
StopDrawing()
Gosub Bomben
DisplaySprite(0,PlayerX,PlayerY)
DisplaySprite(6,PlayerX,PlayerY-1) ; Oben
DisplaySprite(6,PlayerX,PlayerY+SpriteHeight(0)) ; Unten
DisplaySprite(7,PlayerX-1,PlayerY) ; Links
DisplaySprite(7,PlayerX+SpriteWidth(0),PlayerY) ; Rechts
Gosub Wall
Gosub Str
Until KeyboardPushed(#PB_Key_Escape)
End
Str:
If Moving = 0
If KeyboardPushed(#PB_Key_Up) And Up = 0
Moving = 1
EndIf
If KeyboardPushed(#PB_Key_Down) And Down = 0
Moving = 3
EndIf
If KeyboardPushed(#PB_Key_Left) And Left = 0
Moving = 4
EndIf
If KeyboardPushed(#PB_Key_Right) And Right = 0
Moving = 2
EndIf
If KeyboardPushed(#PB_Key_Space)
AddBombe(2,PlayerX,PlayerY,2) ; Wichtig! Die letzte Zahl ist der
EndIf ; Radius der Bombe
EndIf
If Moving = 1
If Delay > 0
Delay - 1
PlayerY - 2
If Delay = 0
Moving = 0
Delay = 30
EndIf
EndIf
EndIf
If Moving = 2
If Delay > 0
Delay - 1
PlayerX + 2
If Delay = 0
Moving = 0
Delay = 30
EndIf
EndIf
EndIf
If Moving = 3
If Delay > 0
Delay - 1
PlayerY + 2
If Delay = 0
Moving = 0
Delay = 30
EndIf
EndIf
EndIf
If Moving = 4
If Delay > 0
Delay - 1
PlayerX - 2
If Delay = 0
Moving = 0
Delay = 30
EndIf
EndIf
EndIf
Return
Bomben:
ForEach Bombe()
DisplayTransparentSprite(Bombe()\Image,Bombe()\X,Bombe()\Y)
Next
ForEach Bombe()
Bombe()\Delay - 1
If Bombe()\Delay = 0
AddReihe(Bombe()\X,Bombe()\Y,Bombe()\Starke,1)
AddReihe(Bombe()\X,Bombe()\Y,Bombe()\Starke,2)
AddReihe(Bombe()\X,Bombe()\Y,Bombe()\Starke,3)
AddReihe(Bombe()\X,Bombe()\Y,Bombe()\Starke,4)
DeleteElement(Bombe())
EndIf
Next
ForEach Expl()
DisplayTransparentSprite(Expl()\Image,Expl()\X,Expl()\Y)
Next
ForEach Expl()
If Expl()\Delay > 0
Expl()\Delay - 1
If Expl()\Delay = 0
DeleteElement(Expl())
EndIf
EndIf
Next
;Collosion zwischen Bombe und Explosion
ForEach Bombe()
ForEach Expl()
If SpriteCollision(Expl()\Image,Expl()\X,Expl()\Y,Bombe()\Image,Bombe()\X,Bombe()\Y)
Bombe()\Delay = 2
EndIf
Next
Next
Return
Wall:
ForEach Wall()
DisplaySprite(Wall()\Image,Wall()\X,Wall()\Y)
Next
Up = 0
Down = 0
Right = 0
Left = 0
ForEach Wall()
If SpriteCollision(Wall()\Image,Wall()\X,Wall()\Y,6,PlayerX,PlayerY-1)
Up = 1
StartDrawing(ScreenOutput())
DrawingMode(1)
DrawText(600,0,"Up",#White)
StopDrawing()
EndIf
If SpriteCollision(Wall()\Image,Wall()\X,Wall()\Y,6,PlayerX,PlayerY+SpriteHeight(0))
Down = 1
StartDrawing(ScreenOutput())
DrawingMode(1)
DrawText(600,15,"Down",#White)
StopDrawing()
EndIf
If SpriteCollision(Wall()\Image,Wall()\X,Wall()\Y,7,PlayerX+SpriteWidth(0),PlayerY)
Right = 1
StartDrawing(ScreenOutput())
DrawingMode(1)
DrawText(600,30,"Right",#White)
StopDrawing()
EndIf
If SpriteCollision(Wall()\Image,Wall()\X,Wall()\Y,7,PlayerX-1,PlayerY)
Left = 1
StartDrawing(ScreenOutput())
DrawingMode(1)
DrawText(600,45,"Left",#White)
StopDrawing()
EndIf
Next
ForEach Wall()
If Wall()\Zerstorbar = 1
ForEach Expl()
If SpriteCollision(Wall()\Image,Wall()\X,Wall()\Y,Expl()\Image,Expl()\X,Expl()\Y)
Wall()\Kill = 1
EndIf
Next
EndIf
Next
ForEach Wall()
If Wall()\Kill = 1
DeleteElement(Wall())
EndIf
Next
Return
Vielleicht weiß ja auch einer, wie das bei dem Original gemacht wurde.
Ich hoffe, der Code ist verständlich.
lg Milchshake