pong für zwei problem
Verfasst: 19.12.2005 20:27
Moin Moin!
Also bin ziemlich neu hier und überhaupt Einsteiger in der Welt des Programmierens. Zur Zeit arbeite ich an einem kleinem Spiel das jeder kennt. Es handelt sich um Pong für zwei Spieler. Es funktioniert schon ganz gut doch sobald der ball ins aus geht wird abgebrochen obwohl er die punkte zählen soll und erst ab einem betimmten wert abgebrochen werden soll. wär cool wenn mir einer von euch mal ein bisschen auf die sprünge helfen könnte!!
danke schon mal im voraus!!!!
InitSprite()
InitKeyboard()
OpenScreen(640,480,16,"pong_für_zwei")
DefType.w
Global ballx
Global bally
Global bewegx
Global bewegy
Global schlaegerux
Global schlaegeruy
Global schlaegerox
Global schlaegeroy
Global punkteu
Global punkteo
ballx = 319
bally = 239
a =1
b = 1
bewegx = a
bewegy = b
schlaegerux = 304 ; da der schlager 30 pixel breit ist
schlaegeruy = 469
schlaegerox = 304
schaegeroy = 0
punkteu = 0
punkteo = 0
If punkteu < 5 Or punkteo < 5
Repeat
ClearScreen(0,0,0)
StartDrawing(ScreenOutput())
FrontColor(255,255,255)
Box(0,0,20,479)
Box(619,0,20,479)
Box(ballx-1,bally-1,3,3)
FrontColor(055,099,243)
Box(schlaegerux,schlaegeruy,30,10)
FrontColor(132,203,123)
Box(schlaegerox,schlaegeroy,30,10)
StopDrawing()
FlipBuffers()
ExamineKeyboard()
If KeyboardPushed(#pb_key_left)
schlaegerux -2
EndIf
If KeyboardPushed(#pb_key_right)
schlaegerux + 2
EndIf
If schlaegerux < 21
schlaegerux = 21
EndIf
If schlaegerux > 588
schlaegerux = 588
EndIf
If KeyboardPushed(#pb_key_a)
schlaegerox -2
EndIf
If KeyboardPushed(#pb_key_d)
schlaegerox + 2
EndIf
If schlaegerox < 21
schlaegerox = 21
EndIf
If schlaegerox > 588
schlaegerox = 588
EndIf
ballx + bewegx
bally + bewegy
If ballx > 619
bewegx = -a
EndIf
If ballx < 20
bewegx = a
EndIf
If ballx > schlaegerux - 1 And ballx < schlaegerux + 29 And bally >schlaegeruy -1 And bally < schlaegeruy + 9
bewegy = -b
EndIf
If ballx > schlaegerox -1 And ballx < schlaegerox + 29 And bally > schlaegeroy -1 And bally < schlaegeroy + 9
bewegy = b
EndIf
If bally < 0
punkteu + 1
EndIf
If bally > 479
punkteo +1
EndIf
Until KeyboardPushed(1) Or punkteu = 5 Or punkteo = 5
EndIf
Also bin ziemlich neu hier und überhaupt Einsteiger in der Welt des Programmierens. Zur Zeit arbeite ich an einem kleinem Spiel das jeder kennt. Es handelt sich um Pong für zwei Spieler. Es funktioniert schon ganz gut doch sobald der ball ins aus geht wird abgebrochen obwohl er die punkte zählen soll und erst ab einem betimmten wert abgebrochen werden soll. wär cool wenn mir einer von euch mal ein bisschen auf die sprünge helfen könnte!!
danke schon mal im voraus!!!!
InitSprite()
InitKeyboard()
OpenScreen(640,480,16,"pong_für_zwei")
DefType.w
Global ballx
Global bally
Global bewegx
Global bewegy
Global schlaegerux
Global schlaegeruy
Global schlaegerox
Global schlaegeroy
Global punkteu
Global punkteo
ballx = 319
bally = 239
a =1
b = 1
bewegx = a
bewegy = b
schlaegerux = 304 ; da der schlager 30 pixel breit ist
schlaegeruy = 469
schlaegerox = 304
schaegeroy = 0
punkteu = 0
punkteo = 0
If punkteu < 5 Or punkteo < 5
Repeat
ClearScreen(0,0,0)
StartDrawing(ScreenOutput())
FrontColor(255,255,255)
Box(0,0,20,479)
Box(619,0,20,479)
Box(ballx-1,bally-1,3,3)
FrontColor(055,099,243)
Box(schlaegerux,schlaegeruy,30,10)
FrontColor(132,203,123)
Box(schlaegerox,schlaegeroy,30,10)
StopDrawing()
FlipBuffers()
ExamineKeyboard()
If KeyboardPushed(#pb_key_left)
schlaegerux -2
EndIf
If KeyboardPushed(#pb_key_right)
schlaegerux + 2
EndIf
If schlaegerux < 21
schlaegerux = 21
EndIf
If schlaegerux > 588
schlaegerux = 588
EndIf
If KeyboardPushed(#pb_key_a)
schlaegerox -2
EndIf
If KeyboardPushed(#pb_key_d)
schlaegerox + 2
EndIf
If schlaegerox < 21
schlaegerox = 21
EndIf
If schlaegerox > 588
schlaegerox = 588
EndIf
ballx + bewegx
bally + bewegy
If ballx > 619
bewegx = -a
EndIf
If ballx < 20
bewegx = a
EndIf
If ballx > schlaegerux - 1 And ballx < schlaegerux + 29 And bally >schlaegeruy -1 And bally < schlaegeruy + 9
bewegy = -b
EndIf
If ballx > schlaegerox -1 And ballx < schlaegerox + 29 And bally > schlaegeroy -1 And bally < schlaegeroy + 9
bewegy = b
EndIf
If bally < 0
punkteu + 1
EndIf
If bally > 479
punkteo +1
EndIf
Until KeyboardPushed(1) Or punkteu = 5 Or punkteo = 5
EndIf