Eigentlich sollte ich ja Delphi Programmieren.....
Verfasst: 15.10.2008 10:07
Tja, wat soll ich sagen
Edit: Bessere Version, alte VErsion weiter unten:
Ne schönheit ist der Code nicht, aber für 10 Minuten programmieren (und nebenbei noch Delphi programmieren) find ich´s garnicht mal schlecht.
Steuerung:
w
s
î
|
\/

Edit: Bessere Version, alte VErsion weiter unten:
Code: Alles auswählen
;============================================
;==========FENSTER-PONG======================
;===================by Franky========
;===================Copyright 2008===========
;============================================
;============================================
;============================================
Enumeration
#Player1
#player2
#Ball
EndEnumeration
Structure Player
x.l
y.l
move.l
bmove.f
EndStructure
Structure Ball
x.l
y.l
movx.f
movy.f
EndStructure
ExamineDesktops()
Global Dim Player.Player(1)
Global Ball.Ball
Player(0)\x=10
Player(0)\y=10
player(0)\bmove=5
player(0)\move=25
Player(1)\x=DesktopWidth(0)-110
Player(1)\y=10
player(1)\bmove=5
player(1)\move=25
Ball\x=500
Ball\y=300
Ball\movx=6
Ball\movy=7
Structure Desk
width.l
height.l
EndStructure
For a=0 To 1
OpenWindow(a,Player(a)\x,Player(a)\y,50,200,"Player"+Str(a),#PB_Window_Normal)
StickyWindow(a,#True)
Next
OpenWindow(#ball,Ball\x,Ball\y,50,50,"",#PB_Window_BorderLess)
StickyWindow(#ball,#True)
SetWindowColor(#ball,RGB(255,0,0))
Repeat
While WindowEvent(): Wend
Delay(5)
Until GetAsyncKeyState_(#VK_SPACE)<>0
Repeat
While WindowEvent():Wend
Delay(15)
Ball\x=Ball\x+Ball\movx
Ball\y=Ball\y+Ball\movy
ResizeWindow(#Ball,BAll\x,Ball\y,#PB_Ignore,#PB_Ignore)
For a=0 To 1
ResizeWindow(a,Player(a)\x,Player(a)\y,#PB_Ignore,#PB_Ignore)
Next
If GetAsyncKeyState_(#VK_W)<>0
Player(0)\y=Player(0)\y-Player(0)\move
If Player(0)\y<0
Player(0)\y=0
EndIf
EndIf
If GetAsyncKeyState_(#VK_S)<>0
Player(0)\y=Player(0)\y+Player(0)\move
If Player(0)\y>DesktopHeight(0)-100
Player(0)\y=DesktopHeight(0)-100
EndIf
EndIf
If GetAsyncKeyState_(#VK_UP)<>0
Player(1)\y=Player(1)\y-Player(1)\move
If Player(1)\y<0
Player(1)\y=0
EndIf
EndIf
If GetAsyncKeyState_(#VK_DOWN)<>0
Player(1)\y=Player(1)\y+Player(1)\move
If Player(1)\y>DesktopHeight(0)-200
Player(1)\y=DesktopHeight(0)-200
EndIf
EndIf
If Ball\movx<0
If Ball\x<Player(0)\x+WindowWidth(0) And (Ball\y>Player(0)\y-50) And Ball\y<Player(0)\y+WindowHeight(#Player1)
Player(1)\bmove=Player(1)\bmove+0.5
Ball\movx=(6+Random(Player(1)\bmove))
EndIf
EndIf
If Ball\movx>0
If Ball\x+WindowWidth(#Ball)>Player(1)\x And (Ball\y>Player(1)\y-50) And Ball\y<Player(1)\y+WindowHeight(#Player2)
Player(0)\bmove=Player(0)\bmove+0.5
Ball\movx=-(6+Random(Player(0)\bmove))
EndIf
EndIf
If Ball\x<0
quit=2
ElseIf Ball\x>DesktopWidth(0)-WindowWidth(#ball)
quit=1
EndIf
If Ball\y<0 And Ball\movy<0
Ball\movy=(6+Random(5))
EndIf
If Ball\y>DesktopHeight(0) And Ball\movy>0
Ball\movy=-(6+Random(5))
EndIf
Until quit<>0
MessageRequester("Gewinner:","Gewonnen hat Spieler"+Str(quit))
Code: Alles auswählen
;============================================
;==========FENSTER-PONG======================
;===================by Franky========
;===================Copyright 2008===========
;============================================
;============================================
;============================================
Enumeration
#Player1
#player2
#Ball
EndEnumeration
Structure Player
x.l
y.l
move.l
EndStructure
Structure Ball
x.l
y.l
movx.f
movy.f
EndStructure
ExamineDesktops()
Global Dim Player.Player(1)
Global Ball.Ball
Player(0)\x=10
Player(0)\y=10
player(0)\move=25
Player(1)\x=DesktopWidth(0)-110
Player(1)\y=10
player(1)\move=25
Ball\x=500
Ball\y=300
Ball\movx=12
Ball\movy=14
Structure Desk
width.l
height.l
EndStructure
For a=0 To 1
OpenWindow(a,Player(a)\x,Player(a)\y,50,200,"Player"+Str(a),#PB_Window_Normal)
StickyWindow(a,#True)
Next
OpenWindow(#ball,Ball\x,Ball\y,50,50,"",#PB_Window_BorderLess)
StickyWindow(#ball,#True)
SetWindowColor(#ball,RGB(255,0,0))
Repeat
While WindowEvent():Wend
Delay(5)
Ball\x=Ball\x+Ball\movx
Ball\y=Ball\y+Ball\movy
ResizeWindow(#Ball,BAll\x,Ball\y,#PB_Ignore,#PB_Ignore)
For a=0 To 1
ResizeWindow(a,Player(a)\x,Player(a)\y,#PB_Ignore,#PB_Ignore)
Next
If GetAsyncKeyState_(#VK_W)<>0
Player(0)\y=Player(0)\y-Player(0)\move
If Player(0)\y<0
Player(0)\y=0
EndIf
EndIf
If GetAsyncKeyState_(#VK_S)<>0
Player(0)\y=Player(0)\y+Player(0)\move
If Player(0)\y>DesktopHeight(0)-100
Player(0)\y=DesktopHeight(0)-100
EndIf
EndIf
If GetAsyncKeyState_(#VK_UP)<>0
Player(1)\y=Player(1)\y-Player(1)\move
If Player(1)\y<0
Player(1)\y=0
EndIf
EndIf
If GetAsyncKeyState_(#VK_DOWN)<>0
Player(1)\y=Player(1)\y+Player(1)\move
If Player(1)\y>DesktopHeight(0)-200
Player(1)\y=DesktopHeight(0)-200
EndIf
EndIf
If Ball\movx<0
If Ball\x<Player(0)\x+WindowWidth(0) And (Ball\y>Player(0)\y-50) And Ball\y<Player(0)\y+WindowHeight(#Player1)
Ball\movx=(10+Random(5))
EndIf
EndIf
If Ball\movx>0
If Ball\x>Player(1)\x And (Ball\y>Player(1)\y-50) And Ball\y<Player(1)\y+WindowHeight(#Player2)
Ball\movx=-(10+Random(5))
EndIf
EndIf
If Ball\x<0
quit=1
ElseIf Ball\x>1180
quit=1
EndIf
If Ball\y<0 And Ball\movy<0
Ball\movy=(10+Random(5))
EndIf
If Ball\y>DesktopHeight(0) And Ball\movy>0
Ball\movy=-(10+Random(5))
EndIf
Until quit=1
Steuerung:
w
s
î
|
\/