Problem beim Erstellen eines Pong-Spieles, bitte Helfen.
Verfasst: 18.05.2005 20:23
Hi liebe PB com,
ich habe ein problem mit den Tutorial was man auf purebasic.de findet.
Ich bin an der stelle mit dem erstellen des Pong spiels und irgendwie funzt es nicht, nicht nur meines sondern auch das aus dem Tutorium.
hier mal mein code:
So ist alles ok nur bewegt sich der ball nicht. Nur warum?
Edit by Kiffi: Betreff geändert
ich habe ein problem mit den Tutorial was man auf purebasic.de findet.
Ich bin an der stelle mit dem erstellen des Pong spiels und irgendwie funzt es nicht, nicht nur meines sondern auch das aus dem Tutorium.
hier mal mein code:
Code: Alles auswählen
InitSprite()
InitKeyboard()
OpenScreen(640,480,16,"Pong")
Global Ball_x .w
Global Ball_y .w
Global Schlaeger_x .w
Global Schlaeger_y .w
Global Ball_Beweg_x .w
Global Ball_Beweg_y .w
Ball_x = 319
Ball_y = 239
Ball_Beweg_x = -1
Ball_Beweg_y = -1
Schlaeger_x = 639 - 10
Schlaeger_y = 479 - (30/2)
Repeat
FlipBuffers()
ClearScreen(0,0,0)
StartDrawing(ScreenOutput())
FrontColor(255,255,255)
Box(0,0,20,480)
Box(0,0,640,20)
Box(0,460,640,20)
Box(Schlaeger_x,Schlaeger_y,10,30)
Box(Ball_x-1,Ball_y-1,3,3)
StopDrawing()
ExamineKeyboard()
If KeyboardPushed (200)
Schlaeger_y - 1
EndIf
If KeyboardPushed (208)
Schlaeger_y +1
EndIf
If Schlaeger_y < 21
Schlaeger_y = 20
ElseIf Schlaeger_y > 460 - 30
Schlaeger_y = 460 - 30
EndIf
Ball_Beweg_x + Ball_x
Ball_Beweg_y + Ball_y
If Ball_x < 20
Ball_Beweg_x = 1
EndIf
If Ball_y < 20
Ball_Beweg_y = 1
EndIf
If Ball_y < 460
Ball_Beweg_y = -1
EndIf
If Ball_x > Schlaeger_y And Ball_x < Schlaeger_x + 10 And Ball_y > Schlaeger_y And Ball_y < Schlaeger_y + 30
Ball_Beweg_x = - 1
EndIf
Until KeyboardPushed(1) Or Ball_x = 640
Edit by Kiffi: Betreff geändert