Da fällt mir ein, ich kann ja den Code hier rein packen...
Code: Alles auswählen
Global GameState
Global ScreenWidth
Global ScreenHeight
Global ScreenResolution
Global FirstPlayerPositionY
Global SecondPlayerPositionY
Global PlayerMovementYUp
Global PlayerMovementYDown
Global PongX
Global PongY
Global Movement
Global Score
Global Points
Global Acceleration
GameState = 0
Score = 0
Points = 0
PlayerMovementYUp = 4
PlayerMovementYDown = 4
Acceleration = 3
Procedure SetScreenResolution()
If OpenWindow(0, 0, 0, 250, 150, #PB_Window_ScreenCentered | #PB_Window_SystemMenu, "Ping Pong Presettings")
If CreateGadgetList(WindowID())
TextGadget(0, 10, 18, 100, 15, "Screenresolution:")
ComboBoxGadget(1, 120, 15, 125, 15)
AddGadgetItem(1, -1, "640x480")
AddGadgetItem(1, -1, "800x600")
AddGadgetItem(1, -1, "1024x768")
AddGadgetItem(1, -1, "1280x1024")
ButtonGadget(3, 15, 120, 100, 25, "OK", #PB_Button_Default)
ButtonGadget(4, 135, 120, 100, 25, "Exit")
EndIf
EndIf
EndProcedure
Procedure InitializeGame()
If InitKeyboard() = 0
MessageRequester("Error", "Couldn't intialize DirectInput!")
End
EndIf
;If InitSound() = 0
;MessageRequester("Error", "Couldn't initialize DirectSound!")
;End
;EndIf
If InitSprite() = 0
MessageRequester("Error", "Couldn't initialize DirectDraw!")
End
EndIf
If OpenScreen(ScreenWidth, ScreenHeight, 32, "Ping Pong") = 0
MessageRequester("Error", "Couldn't open Screen!")
End
EndIf
SetFrameRate(30)
SetRefreshRate(60)
EndProcedure
Procedure CreateGameRessources()
CreateSprite(0, 32, 256)
CreateSprite(1, 32, 32)
CreateSprite(2, 32, 256)
StartDrawing(SpriteOutput(0))
Box(0, 0, 256, 256, RGB(255, 255, 255))
StopDrawing()
StartDrawing(SpriteOutput(1))
Box(0, 0, 256, 256, RGB(255, 255, 255))
StopDrawing()
StartDrawing(SpriteOutput(2))
Box(0, 0, 256, 256, RGB(255, 255, 255))
StopDrawing()
ExamineScreenModes()
PongX = ScreenWidth/2
PongY = ScreenHeight/2
Movement = 1
FirstPlayerPositionY = ScreenHeight/2-128
SecondPlayerPositionY = ScreenHeight/2-128
EndProcedure
Procedure StartNewRound()
PongX = ScreenWidth/2
PongY = ScreenHeight/2
Movement = 1
FirstPlayerPositionY = ScreenHeight/2-128
SecondPlayerPositionY = ScreenHeight/2-128
Score = 0
Points = 0
EndProcedure
SetScreenResolution()
SetGadgetState(1, 3)
Repeat
Select GameState
Case 0
Event = WaitWindowEvent()
WindowID = EventWindowID()
GadgetID = EventGadgetID()
EventType = EventType()
If Event = #PB_EventGadget
If GadgetID = 3
ScreenResolution = GetGadgetState(1)
Select ScreenResolution
Case 0
ScreenWidth = 640
ScreenHeight = 480
Case 1
ScreenWidth = 800
ScreenHeight = 600
Case 2
ScreenWidth = 1024
ScreenHeight = 768
Case 3
ScreenWidth = 1280
ScreenHeight = 1024
Default
ScreenWidth = 1280
ScreenHeight = 1024
EndSelect
CloseWindow(0)
InitializeGame()
CreateGameRessources()
GameState = 1
ElseIf GadgetID = 4
End
EndIf
EndIf
Case 1
ExamineKeyboard()
ClearScreen(0, 0, 0)
DisplaySprite(0, 25, FirstPlayerPositionY)
DisplaySprite(1, PongX, PongY)
DisplaySprite(2, ScreenWidth-57, PongY-128)
If KeyboardPushed(#PB_Key_Up)
FirstPlayerPositionY = FirstPlayerPositionY-PlayerMovementYUp
ElseIf KeyboardPushed(#PB_Key_Down)
FirstPlayerPositionY = FirstPlayerPositionY+PlayerMovementYDown
EndIf
If FirstPlayerPositionY = 0
PlayerMovementYUp = 0
ElseIf FirstPlayerPositionY <> 0
PlayerMovementYUp = 4
EndIf
If FirstPlayerPositionY = ScreenHeight-256
PlayerMovementYDown = 0
ElseIf FirstPlayerPositionY <> ScreenHeight-256
PlayerMovementYDown = 4
EndIf
If SpriteCollision(0, 25, FirstPlayerPositionY, 1, PongX, PongY)
Movement = 0
Score+1
Acceleration+1
ElseIf SpriteCollision(2, ScreenWidth-57, SecondPlayerPositionY, 1, PongX, PongY)
Movement = 1
Points+1
Acceleration+1
EndIf
;{ Geschwindigkeitssteigerung
Select Movement
Case 0
PongX = PongX+Acceleration
Case 1
PongX = PongX-Acceleration
EndSelect
;}
Score$ = Str(Score)
Points$ = Str(Points)
If PongX < 0
Score$ = "Failed!"
Points$ = "Winner!"
ElseIf PongX > ScreenWidth
Points$ = "Failed!"
Score$ = "Winner!"
EndIf
StartDrawing(ScreenOutput())
DrawingMode(1) : Locate(0, 0) : FrontColor(255, 255, 255) : DrawText("Score: "+Score$)
DrawingMode(1) : Locate(ScreenWidth/2-TextLength("New Round: Return Exit: Escape")/2, 0) : FrontColor(255, 255, 255) : DrawText("New Round: Return Exit: Escape")
DrawingMode(1) : Locate(ScreenWidth-TextLength("Score: "+Points$), 0) : FrontColor(255, 255, 255) : DrawText("Score: "+Points$)
Line(0, 18, ScreenWidth, 0, RGB(255, 255, 255))
Line(0, ScreenHeight-20, ScreenWidth, 0, RGB(50, 50, 50))
DrawingMode(1) : Locate(0, ScreenHeight-18) : FrontColor(50, 50, 50) : DrawText("Old School Ping Pong 2006 by theNameless.net Software, visit http://www.theNameless.de/Software/")
StopDrawing()
If KeyboardReleased(#PB_Key_Return)
StartNewRound()
EndIf
If KeyboardReleased(#PB_Key_Escape)
End
EndIf
FlipBuffers()
EndSelect
ForEver
Vielleicht hilfts manchen weiter... ... so als Code Vorlage(Loserkid?)
Und ich weiß, ich muss auch sagen, den habe ich in kurzer Zeit sehr schlampig gemacht! Mir gings nur darum, ein Ping Pong Spiel in kurzer Zeit zu machen..
Ich hatte ja schon gesagt, is noch nicht ganz fertig.