Colisionscode streikt?!
Verfasst: 30.05.2006 20:43
Hi
Ich sitz grad an einen Weltraumshooter hab aber ein Problem mit den Colisionscode.
Bei den Zeilen
LGJaeger()\Shield - GatlingshootI()\Schildschaden
test - GatlingshootI()\Schildschaden
zieht er nicht wie vorgeschrieben 50 ab , sondern einen zufälligen wert
über die angegebenen 50 (hab ich am Screenautput "test" gesehen)
Weiß jemand wodran das liegt ?
ich stell mal alles rein was mit den 2 Objeckten zu tun hatt .
Ich sitz grad an einen Weltraumshooter hab aber ein Problem mit den Colisionscode.
Code: Alles auswählen
...
If SpriteCollision(1,GatlingshootI()\x,GatlingshootI()\y,2, LGJaeger()\x, LGJaeger()\y) And LGJaeger()\Shield > 0
DeleteElement(GatlingshootI())
ResetList(GatlingshootI())
While NextElement(GatlingshootI())
LGJaeger()\Shield - GatlingshootI()\Schildschaden
test - GatlingshootI()\Schildschaden
...
(edit)
ResetList(GatlingshootI())
While NextElement(GatlingshootI())
GatlingshootI()\Schildschaden = 50
Wend
(edit)
LGJaeger()\Shield - GatlingshootI()\Schildschaden
test - GatlingshootI()\Schildschaden
zieht er nicht wie vorgeschrieben 50 ab , sondern einen zufälligen wert
über die angegebenen 50 (hab ich am Screenautput "test" gesehen)
Weiß jemand wodran das liegt ?
ich stell mal alles rein was mit den 2 Objeckten zu tun hatt .
Code: Alles auswählen
InitMovie()
InitSprite()
InitKeyboard()
InitMouse()
InitSound()
OpenScreen(1024,768,32,"name")
Global FeuerateRoketI.l
Global MaxLGJaeger.l
Global FeuerateGatlingshootI.l
Global erstellLGJaeger.l
Global GattlingshootIausgeruestet.l
Global GatlingshootsI.l
Global Treffer.l
Global test.l
test = 0
;STRUCTUREN
Structure GatlingshootI
x.l
y.l
speedX.l
speedY.l
Feuerate.l
Schildschaden.l
Huellenschaden.l
EndStructure
NewList GatlingshootI.GatlingshootI()
Structure LGJaeger
x.l
y.l
speedX.l
speedY.l
Armor.l
Shield.l
EndStructure
NewList LGJaeger.LGJaeger()
; PROZEDUREN
Procedure AddGatlingshootI (x, y, speedX, speedY)
AddElement (GatlingshootI())
GatlingshootI()\x = x
GatlingshootI()\y = y
GatlingshootI()\speedX = speedX
GatlingshootI()\speedY = speedY
GatlingshootI()\Feuerate = Feuerate
GatlingshootI()\Schildschaden = Schildschaden
GatlingshootI()\Huellenschaden = Huellenschaden
EndProcedure
Procedure AddLGJaeger(x,y,speedX,speedY)
AddElement(LGJaeger())
LGJaeger()\x = x
LGJaeger()\y = y
LGJaeger()\speedX = speedX
LGJaeger()\speedY = speedY
LGJaeger()\Armor = Armor
LGJaeger()\Shield = Shield
EndProcedure
; MAIN LOOP
Repeat
ExamineMouse()
ExamineKeyboard()
ClearScreen(0,255,0)
If FeuerateGatlingshootI > 0
FeuerateGatlingshootI - 1
EndIf
; ADD'S
If MaxLGJaeger < 40 And erstellLGJaeger <=0
AddLGJaeger(1000,Random(600),-2,0)
erstellLGJaeger + 20
LGJaeger()\Armor = 100
LGJaeger()\Shield = 200
MaxLGJaeger + 1
EndIf
If erstellLGJaeger > 0
erstellLGJaeger - 1
EndIf
If MaxSpieler = 0
AddSpieler(400,400,2,2)
MaxSpieler + 1
EndIf
;collisionen
ResetList(LGJaeger())
While NextElement(LGJaeger())
ResetList(GatlingshootI())
While NextElement(GatlingshootI())
If SpriteCollision(1,GatlingshootI()\x,GatlingshootI()\y,2, LGJaeger()\x, LGJaeger()\y) And LGJaeger()\Shield <= 0
DeleteElement(GatlingshootI())
ResetList(GatlingshootI())
While NextElement(GatlingshootI())
LGJaeger()\Armor - GatlingshootI()\Huellenschaden / (GatlingshootsI / 2 )
Wend
GatlingshootsI - 1
Treffer + 1
EndIf
Wend
Wend
ResetList(LGJaeger())
While NextElement(LGJaeger())
ResetList(GatlingshootI())
While NextElement(GatlingshootI())
If SpriteCollision(1,GatlingshootI()\x,GatlingshootI()\y,2, LGJaeger()\x, LGJaeger()\y) And LGJaeger()\Shield > 0
DeleteElement(GatlingshootI())
ResetList(GatlingshootI())
While NextElement(GatlingshootI())
LGJaeger()\Shield - GatlingshootI()\Schildschaden
test - GatlingshootI()\Schildschaden
Wend
GatlingshootsI - 1
Treffer + 1
EndIf
Wend
Wend
;STRUCKTUREIGENSCHAFTEN
ResetList(GatlingshootI())
While NextElement(GatlingshootI())
If GatlingshootI()\x > 1024 : DeleteElement(GatlingshootI()):GatlingshootsI - 1
ElseIf GatlingshootI()\x < 0 : DeleteElement(GatlingshootI()):GatlingshootsI - 1
ElseIf GatlingshootI()\y >786 : DeleteElement(GatlingshootI()):GatlingshootsI - 1
ElseIf GatlingshootI()\y < 0 : DeleteElement(GatlingshootI()):GatlingshootsI - 1
EndIf
Wend
ResetList(GatlingshootI())
While NextElement(GatlingshootI())
GatlingshootI()\Huellenschaden = 50
GatlingshootI()\Schildschaden = 50
Wend
; STEUERUNG
ResetList(Spieler())
While NextElement(Spieler())
DisplayTransparentSprite(0,Spieler()\x, Spieler()\y)
If KeyboardPushed(#PB_key_Right)
Spieler()\x + Spieler()\speedX
EndIf
If KeyboardPushed(#PB_key_Left)
Spieler()\x - Spieler()\speedX
EndIf
If KeyboardPushed(#PB_key_Down)
Spieler()\y + Spieler()\speedY
EndIf
If KeyboardPushed(#PB_key_Up)
Spieler()\y - Spieler()\speedY
EndIf
If KeyboardPushed (#PB_key_LeftControl) And FeuerateGatlingshootI = 0
AddGatlingshootI(Spieler()\x+25, Spieler()\y -2, 7, 0)
FeuerateGatlingshootI = 5
GatlingshootsI + 1
AddGatlingshootI(Spieler()\x, Spieler()\y+19, 7, 0)
FeuerateGatlingshootI = 5
GatlingshootsI + 1
EndIf
Wend
ResetList(LGJaeger())
While NextElement(LGJaeger())
If LGJaeger()\x > 1200 : DeleteElement(LGJaeger()):MaxLGJaeger-1
ElseIf LGJaeger()\x < 0 : DeleteElement(LGJaeger()):MaxLGJaeger-1
ElseIf LGJaeger()\y > 600 : DeleteElement(LGJaeger()):MaxLGJaeger-1
ElseIf LGJaeger()\y < 0 : DeleteElement(LGJaeger()):MaxLGJaeger-1
ElseIf LGJaeger()\Armor < 1 : DeleteElement(LGJaeger()):MaxLGJaeger-1
EndIf
Wend
;BILDER
ResetList(GatlingshootI())
While NextElement(GatlingshootI())
DisplayTransparentSprite(3, GatlingshootI()\x, GatlingshootI()\y)
GatlingshootI()\x + GatlingshootI()\speedX
GatlingshootI()\y + GatlingshootI()\speedY
Wend
ResetList(LGJaeger())
While NextElement(LGJaeger())
DisplayTransparentSprite(2,LGJaeger()\x, LGJaeger()\y)
LGJaeger()\x + LGJaeger()\speedX
LGJaeger()\y + LGJaeger()\speedY
Wend
StartDrawing(ScreenOutput())
DrawingMode(1)
Locate(0,0)
FrontColor(0,0,255)
DrawText("Punkte:" + Str(test ))
StopDrawing ()
FlipBuffers()
Until KeyboardPushed(1):End