ich habe ein Problem. Naja wie ihr seht (im "mein 2d shooter" thread) hat mir sunny geholfen, dass schiessen einzubauen. Es funzt für beide Spieler. Ich wollte fragen, wie man eine Kollision macht? habe überhaupt keine ahnung^^ kann mir das jemand erklären?
Code: Alles auswählen
; Code
Structure bullet_struc
pos_x.w
pos_y.w
speed_x.w
speed_y.w
graphic.w
EndStructure
NewList bullet.bullet_struc()
InitSprite() And InitKeyboard()
PlayerX = 20
PlayerY = 700
PlayerTwoX = 500
PlayerTwoY = 10
OpenScreen(1024, 768, 32, "Muake - 2D Shooter")
; Player one and two
LoadSprite(0,"player1.bmp")
LoadSprite(1,"player2.bmp")
graphic.w = LoadSprite(2,"shoot.bmp")
LoadSprite(3,"player2_explosion.bmp")
Repeat
ClearScreen(0,0,0)
ForEach bullet()
bullet()\pos_x = bullet()\pos_x + bullet()\speed_x
bullet()\pos_y = bullet()\pos_y + bullet()\speed_y
DisplaySprite(bullet()\graphic, bullet()\pos_x, bullet()\pos_y)
If bullet()\pos_y <= 0
DeleteElement(bullet())
EndIf
Next bullet()
DisplayTransparentSprite(0,PlayerX,PlayerY)
DisplayTransparentSprite(1,PlayerTwoX,PlayerTwoY)
FlipBuffers()
If KeyboardPushed(#PB_Key_Right)
PlayerX + 6
EndIf
If KeyboardPushed(#PB_Key_Left)
PlayerX - 6
EndIf
If KeyboardPushed(#PB_Key_D)
PlayerTwoX + 6
EndIf
If KeyboardPushed(#PB_Key_A)
PlayerTwoX - 6
EndIf
If KeyboardPushed(#PB_Key_Space)
If space = 0
space = 1
AddElement(bullet())
bullet()\pos_x = PlayerX
bullet()\pos_y = PlayerY
bullet()\speed_y = -20
bullet()\speed_x = 0
bullet()\graphic = 2
EndIf
Else
space = 0
EndIf
If KeyboardPushed(#PB_Key_LeftAlt)
If alt = 0
alt = 1
AddElement(bullet())
bullet()\pos_x = PlayerTwoX
bullet()\pos_y = PlayerTwoY
bullet()\speed_y = 10
bullet()\speed_x = 1
bullet()\graphic = 2
EndIf
Else
alt = 0
EndIf
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
Ich hoffe es kann mir jemand helfen !!!!!
mfg xsoft