Guten Abend miteinander
ich möchte hier mein Spiel Auto Ball vorstellen um Verbesserungsvorschläge und Anregungen zu bekomme. Ich habe an dem Spiel die letzten zwei Monate gearbeitet, mitlerweile ist es in einer spielbaren Version.
Die neuste Version ist: v1.7 wenn man zwei Spieler wählt kann man mit l ein lan spiel erstellen und auch joinen, jedoch ist diese funktion noch in der beta Phase
Spoiler anzeigen
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=Auto-Ball.ico
#AutoIt3Wrapper_Outfile=Auto-Ball.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Res_Comment=Thanks to http://www.autoit.de
#AutoIt3Wrapper_Res_Description=Auto-Ball
#AutoIt3Wrapper_Res_Fileversion=1.5.0.0
#AutoIt3Wrapper_Res_LegalCopyright=Moritz
#AutoIt3Wrapper_Res_Language=3079
#AutoIt3Wrapper_Res_Field=Author|Moritz
#AutoIt3Wrapper_Res_Field=Author eMail|moritz (at) gmx.at
#AutoIt3Wrapper_Res_Field=Orginaldateiname|Auto Ball.exe
#AutoIt3Wrapper_Res_Field=Produktname|Auto-Ball
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GuiConstants.au3>
#include <GDIPlus.au3>
;#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Sound.au3>
#include <Misc.au3>
#include <Date.au3>
HotKeySet("{ESC}", "_beenden")
HotKeySet("{l}", "_lan_create")
Opt('MustDeclareVars', 1)
Opt('GuiOnEventMode', 1)
Opt ('MouseCoordMode', 0)
Global Const $width = 640
Global Const $height = 400
Global Const $titel = "Auto Ball"
Global Const $version = " v1.5"
Global Const $Testversion = "no" ; "2009/03/28 23:59:59" ;oder "no"
Global $player[2], $player_score[2] = [0,0]
Global $hGUI, $hWnd, $hGraphic, $Bitmap, $Buffer[2], $msg, $hBrush[1] , $background, $rand_dist = 0, $hMatrix, $hImage, $iWidth, $iHeight
Global Const $pi = 3.14159265358979, $radToDeg = 180 / $pi
Global $rotate[2] = [270,90] , $x[2] = [68,572], $y[2] = [200,200], $schwung[2], $auto_radius = 32 ;, $auto_masse = $pi*$auto_radius^2
Global $rotate_abprall[2], $schwung_abprall[2]
Global $ball_rotate, $ball_x = 304, $ball_y = 200, $ball_schwung = 8, $ball_radius = 12 ;, $ball_massse = $pi*$ball_radius^2
Global $ConnectedSocket_join = -1, $ConnectedSocket_host = -1, $IP, $recv
Global $i, $c, $var1, $return
Global $max_speed = 4, $reibung = 0.02, $ball_max_speed = 4, $ball_reibung = 0.01, $game_status, $game_speed = 10
Global Const $WS_EX_COMPOSITED = 0x2000000 ; Gegen "Flackern"
Global $sound_schuss
Global $ConnectedSocket_join = -1, $ConnectedSocket_host = -1
Global $GUI, $button_join, $button_host, $input_ip, $msg, $info, $button_ok, $text[3]
Global $PC_IP = @IPAddress1, $return
;_server("host",$IP) ; (Ob join oder erstellen , Die IP und der Port)
[/autoit] [autoit][/autoit] [autoit];Global $dll = DllOpen("user32.dll")
[/autoit] [autoit][/autoit] [autoit]If $Testversion <> "no" Then _testversion_check ()
[/autoit] [autoit][/autoit] [autoit]$sound_schuss = _SoundOpen("sounds\schuss.wav")
[/autoit] [autoit][/autoit] [autoit]$hGUI = GUICreate($Titel & $version, $width, $height,-1,-1)
$hWnd = WinGetHandle($Titel & $version)
GUISetBkColor (0xFFFFFF)
GUISetOnEvent($GUI_EVENT_CLOSE, "_beenden")
GUISetState(@SW_SHOW)
[/autoit] [autoit][/autoit] [autoit];GUISetCursor(16) ;invisible
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_Startup ()
[/autoit] [autoit][/autoit] [autoit]$hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd)
$Bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $hGraphic)
$Buffer[0] = _GDIPlus_ImageGetGraphicsContext($Bitmap)
_GDIPlus_GraphicsSetSmoothingMode($Buffer, 4)
_GDIPlus_GraphicsClear($Buffer,0xFF000000)
$background = _GDIPlus_ImageLoadFromFile ("gfx\background.gif")
$hBrush[0] = _GDIPlus_BrushCreateSolid (0xFF80FF00)
$Buffer[1] = _GDIPlus_ImageGetGraphicsContext($Bitmap)
$hImage = _GDIPlus_ImageLoadFromFile("gfx\Auto.gif")
$iWidth = _GDIPlus_ImageGetWidth ($hImage) ;/ 2
$iHeight = _GDIPlus_ImageGetHeight ($hImage); / 2
_menue ()
[/autoit] [autoit][/autoit] [autoit]While 1
Sleep (100)
WEnd
Func _main ()
[/autoit] [autoit][/autoit] [autoit];##### Player1 ########################################################
[/autoit] [autoit][/autoit] [autoit]If _IsPressed ("27") Then $Rotate[0] -= 5
If _IsPressed ("25") Then $Rotate[0] += 5
If _IsPressed ("26") Then $schwung[0] -= 0.1
If _IsPressed ("28") Then $schwung[0] += 0.1
;##### Player2 ########################################################
;If $game_status <> "Bot" Then
If _IsPressed ("44") Then $Rotate[1] -= 5
If _IsPressed ("41") Then $Rotate[1] += 5
If _IsPressed ("57") Then $schwung[1] -= 0.1
If _IsPressed ("53") Then $schwung[1] += 0.1
;EndIf
;##### Korrektur & Limit ##############################################
For $i = 0 To 1 Step 1
[/autoit] [autoit][/autoit] [autoit]If $schwung[$i] < 0 Then
$schwung[$i] += $reibung
ElseIf $schwung[$i] > 0 Then
$schwung[$i] -= $reibung
EndIf
If $schwung_abprall[$i] < 0 Then
$schwung_abprall[$i] += $reibung
ElseIf $schwung_abprall[$i] > 0 Then
$schwung_abprall[$i] -= $reibung
EndIf
If $schwung[$i] >= $max_speed Then $schwung[$i] = $max_speed
If $schwung[$i] <= -$max_speed Then $schwung[$i] = -$max_speed
Next
;##### Collision Seiten ################################################
For $i = 0 To 1 Step 1
[/autoit] [autoit][/autoit] [autoit]If $x[$i] <= 32 + $rand_dist Then
If $schwung[$i] < 0 Then
$x[$i] -= $schwung[$i]
Else
$x[$i] += $schwung[$i]
EndIf
If $schwung[$i] > $schwung_abprall[$i] And $schwung[$i] > 0 Then
$schwung_abprall[$i] = $schwung[$i] * 0.5
$schwung[$i] = 0
$rotate_abprall[$i] = -$rotate[$i]
ElseIf $schwung[$i] < $schwung_abprall[$i] And $schwung[$i] < 0 Then
$schwung_abprall[$i] = $schwung[$i] * 0.5
$schwung[$i] = 0
$rotate_abprall[$i] = -$rotate[$i]
Else
$rotate_abprall[$i] = -$rotate_abprall[$i]
EndIf
EndIf
If $x[$i] >= $width - 32 - $rand_dist Then
If $schwung[$i] > 0 Then
$x[$i] -= $schwung[$i]
Else
$x[$i] += $schwung[$i]
EndIf
If $schwung[$i] > $schwung_abprall[$i] And $schwung[$i] > 0 Then
$schwung_abprall[$i] = $schwung[$i] * 0.5
$schwung[$i] = 0
$rotate_abprall[$i] = -$rotate[$i]
ElseIf $schwung[$i] < $schwung_abprall[$i] And $schwung[$i] < 0 Then
$schwung_abprall[$i] = $schwung[$i] * 0.5
$schwung[$i] = 0
$rotate_abprall[$i] = -$rotate[$i]
Else
$rotate_abprall[$i] = -$rotate_abprall[$i]
EndIf
EndIf
If $y[$i] <= 32 + $rand_dist Then
[/autoit] [autoit][/autoit] [autoit]; $rotate_abprall[$i] = (($rotate[$i] + 90) * -1) - 90
If $schwung[$i] < 0 Then
$y[$i] -= $schwung[$i]
Else
$y[$i] += $schwung[$i]
EndIf
If $schwung[$i] > $schwung_abprall[$i] And $schwung[$i] > 0 Then
$schwung_abprall[$i] = $schwung[$i] * 0.5
$schwung[$i] = 0
$rotate_abprall[$i] = (($rotate[$i] + 90) * -1) - 90
ElseIf $schwung[$i] < $schwung_abprall[$i] And $schwung[$i] < 0 Then
$schwung_abprall[$i] = $schwung[$i] * 0.5
$schwung[$i] = 0
$rotate_abprall[$i] = (($rotate[$i] + 90) * -1) - 90
Else
$rotate_abprall[$i] = (($rotate_abprall[$i] + 90) * -1) - 90
EndIf
EndIf
If $y[$i] >= $height - 32 - $rand_dist Then
If $schwung[$i] > 0 Then
$y[$i] -= $schwung[$i]
Else
$y[$i] += $schwung[$i]
EndIf
If $schwung[$i] > $schwung_abprall[$i] And $schwung[$i] > 0 Then
$schwung_abprall[$i] = $schwung[$i] * 0.5
$schwung[$i] = 0
$rotate_abprall[$i] = (($rotate[$i] + 90) * -1) - 90
ElseIf $schwung[$i] < $schwung_abprall[$i] And $schwung[$i] < 0 Then
$schwung_abprall[$i] = $schwung[$i] * 0.5
$schwung[$i] = 0
$rotate_abprall[$i] = (($rotate[$i] + 90) * -1) - 90
Else
$rotate_abprall[$i] = (($rotate_abprall[$i] + 90) * -1) - 90
EndIf
EndIf
Next
If $ball_x <= $ball_radius + $rand_dist Then
$ball_rotate = -$ball_rotate
$ball_x += 1
EndIf
If $ball_x >= $width - $ball_radius - $rand_dist Then
$ball_rotate = -$ball_rotate
$ball_x -= 1
EndIf
If $ball_y <= $ball_radius + $rand_dist Then
$ball_rotate += 90
$ball_rotate = -$ball_rotate
$ball_rotate -= 90
$ball_y += 1
EndIf
If $ball_y >= $height - $ball_radius - $rand_dist Then
$ball_rotate += 90
$ball_rotate = -$ball_rotate
$ball_rotate -= 90
$ball_y -= 1
EndIf
;##### /Collision Seiten ###############################################
[/autoit] [autoit][/autoit] [autoit]If $ball_y > 150 And $ball_y < 218 Then
If $ball_x < 22 + $rand_dist Then
_tor(1)
ElseIf $ball_x > 614 - $rand_dist Then
_tor(0)
EndIf
EndIf
;#### Collisionen #####################################################
[/autoit] [autoit][/autoit] [autoit]For $i = 0 To 1 Step 1
$c = Sqrt (($ball_x - $x[$i]) ^ 2 + ($ball_y - $y[$i]) ^ 2) ;C = Wurzel (A^2+B^2), erst wird Ball_x bzw y von x bzw y subtrahiert.
$var1 = ($ball_x - $x[$i]) / $c ; Verhältnis zwischen a und c zur anschließenden ACos berechnung
If $c <= 32 + $ball_radius Then
_SoundPlay ($sound_schuss)
If $schwung[$i] + $schwung_abprall[$i] < 0 Then
$ball_schwung = $schwung[$i] + $ball_schwung + $schwung_abprall[$i]
Else
$ball_schwung = -$schwung[$i] + $ball_schwung - $schwung_abprall[$i]
EndIf
$ball_rotate = ACos ($var1) * $radToDeg
If $ball_y > $y[$i] Then $ball_rotate = -$ball_rotate
$ball_rotate -= 90
EndIf
Next
$c = Sqrt (($x[1] - $x[0])^2+($y[1] - $y[0])^2) ;C = Wurzel (A^2+B^2)
$var1 = ($x[1] - $x[0]) / $c
If $c <= 64 Then
$rotate_abprall[0] = $rotate[1]
$rotate_abprall[1] = $rotate[0]
If $schwung[1] < $schwung_abprall[0] And $schwung[1] < 0 Then
$schwung_abprall[0] = $schwung[1]
ElseIf $schwung[1] > $schwung_abprall[0] And $schwung[1] > 0 Then
$schwung_abprall[0] = $schwung[1]
Else
$schwung_abprall[0] = $schwung_abprall[1]
EndIf
If $schwung[0] < $schwung_abprall[1] And $schwung[0] < 0 Then
$schwung_abprall[1] = $schwung[0]
ElseIf $schwung[0] > $schwung_abprall[1] And $schwung[0] > 1 Then
$schwung_abprall[1] = $schwung[0]
Else
$schwung_abprall[1] = $schwung_abprall[0]
EndIf
; $schwung_abprall[1] = $schwung[0]
$schwung[0] = 0
$schwung[1] = 0
EndIf
[/autoit] [autoit][/autoit] [autoit];#### /Collisionen ####################################################
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit];#### NPC Spieler #####################################################
[/autoit] [autoit][/autoit] [autoit]If $game_status = "Bot" Then _bot ()
;#### /NPC Spieler ####################################################
If $ball_schwung > 0 Then
$ball_schwung -= $ball_reibung
ElseIf $ball_schwung < 0 Then
$ball_schwung += $ball_reibung
EndIf
If $ball_schwung < -$ball_max_speed Then $ball_schwung = -$ball_max_speed
If $ball_schwung > $ball_max_speed Then $ball_schwung = $ball_max_speed
For $i = 0 To 1 Step 1
$x[$i] += Sin (($rotate[$i])*$Pi/180)*$schwung[$i] ;errechnet x
$y[$i] += Cos (($rotate[$i])*$Pi/180)*$schwung[$i] ;errechnet y
$x[$i] += Sin (($rotate_abprall[$i])*$Pi/180)*$schwung_abprall[$i] ;errechnet x
$y[$i] += Cos (($rotate_abprall[$i])*$Pi/180)*$schwung_abprall[$i] ;errechnet y
Next
$ball_x += Sin (($ball_rotate)*$Pi/180)*$ball_schwung ;errechnet x
$ball_y += Cos (($ball_rotate)*$Pi/180)*$ball_schwung ;errechnet y
_zeichnen ()
EndFunc
[/autoit] [autoit][/autoit] [autoit]Func _menue ()
Local $mGUI, $Button[3], $move_in, $input[2]
$mGUI = GUICreate($Titel, 640, 400,0,25,$WS_POPUP, $WS_EX_MDICHILD + $WS_EX_LAYERED + $WS_EX_COMPOSITED,$hGUI)
GUISetBkColor (0xFFFFFF)
GUICtrlCreatePic("gfx\BK.gif", 0, 0, 640, 400, $WS_BORDER)
GUICtrlSetState(-1, $GUI_DISABLE)
$Button[0] = GUICtrlCreateButton ("1 Spieler",-150,200,140,50)
; $Button[0] = GUICtrlCreateLabel("1 Spieler",250,100,140,50, $SS_CENTER)
GUICtrlSetColor (-1,0xFF0000)
GUICtrlSetFont(-1, 18, 400, 0, "Ellis")
; GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetCursor(-1, 0)
GUICtrlSetState (-1, $GUI_ONTOP)
GUICtrlSetOnEvent (-1,"_info_button")
$Button[1] = GUICtrlCreateButton ("2 Spieler",650,270,140,50)
GUICtrlSetColor (-1,0xFF0000)
GUICtrlSetFont(-1, 18, 400, 0, "Ellis")
GUICtrlSetCursor(-1, 0)
GUICtrlSetState (-1, $GUI_ONTOP)
GUICtrlSetOnEvent (-1,"_info_button")
$Input[0] = GUICtrlCreateInput ("",250,270,140,50)
GUICtrlSetColor (-1,0xFF0000)
GUICtrlSetFont(-1, 18, 400, 0, "Ellis")
GUICtrlSetCursor(-1, 0)
GUICtrlSetOnEvent (-1,"_info_button")
GUICtrlSetState (-1,@SW_HIDE)
$Button[2] = GUICtrlCreatePic ("gfx\Home.gif",10,5,32,32)
; GUICtrlSetColor (-1,0xFF0000)
; GUICtrlSetFont(-1, 18, 400, 0, "Ellis")
; GUICtrlSetImage(-1, "shell32.dll", 22)
GUICtrlSetCursor(-1, 0)
GUICtrlSetState (-1, $GUI_ONTOP)
GUICtrlSetOnEvent (-1,"_info_button")
GUICtrlCreateLabel ($titel & " " & $version, 20, 370)
GUICtrlSetState (-1, $GUI_ONTOP)
GUISetState (@SW_SHOW)
Sleep (1000)
[/autoit] [autoit][/autoit] [autoit]For $move_in = 0 To 400 Step 40
GUICtrlSetPos ($Button[0], -150 + $move_in, 200)
GUICtrlSetPos ($Button[1], 650 - $move_in, 270)
Sleep (10)
Next
While 1
If $msg <> 0 Then
If $msg = 4 Then
$msg = 0
GUICtrlSetState ($Input[0], $GUI_ONTOP)
GUICtrlSetData ($Input[0], "Player1")
GUICtrlSetState ($Input[0], $GUI_FOCUS)
; GUICtrlSetState ($Input[0],@SW_SHOW)
; GUICtrlSetState ($Button[1],@SW_HIDE)
GUICtrlSetData ($Button[0], "OK")
GUICtrlSetPos ($Button[1], $width, $height)
For $move_in = 0 To 400 Step 40
GUICtrlSetPos ($Button[0], 650 - $move_in, 200)
GUICtrlSetPos ($Input[0], -150 + $move_in, 270)
Sleep (10)
Next
While 1
If $msg = 4 Then
AdlibEnable ( "_main" , $game_speed )
$game_status = "Bot"
$Player[0] = GUICtrlRead ($Input[0])
$player[1] = "Crabby"
ExitLoop 2
EndIf
WEnd
ElseIf $msg = 5 Then
GUICtrlSetState ($Input[0], $GUI_ONTOP)
GUICtrlSetData ($Input[0], "Player1")
GUICtrlSetState ($Input[0], $GUI_FOCUS)
; GUICtrlSetState ($Input[0],@SW_SHOW)
; GUICtrlSetState ($Button[1],@SW_HIDE)
GUICtrlSetData ($Button[0], "OK")
GUICtrlSetPos ($Button[1], $width, $height)
For $move_in = 0 To 400 Step 40
GUICtrlSetPos ($Button[0], 650 - $move_in, 200)
GUICtrlSetPos ($Input[0], -150 + $move_in, 270)
Sleep (10)
Next
While 1
If $msg = 4 Then
For $move_in = 0 To 400 Step 40
GUICtrlSetPos ($Button[0], -150 + $move_in, 200)
GUICtrlSetPos ($Input[0], 650 - $move_in, 270)
Sleep (10)
Next
$msg = 0
$Player[0] = GUICtrlRead ($Input[0])
GUICtrlSetData ($Input[0], "Player2")
GUICtrlSetState ($Input[0], $GUI_FOCUS)
While 1
If $msg = 4 Then
$Player[1] = GUICtrlRead ($Input[0])
For $move_in = 0 To 400 Step 40
GUICtrlSetPos ($Button[0], 250 + $move_in, 200)
GUICtrlSetPos ($Input[0], 250 - $move_in, 270)
Sleep (10)
Next
ExitLoop 2
EndIf
Sleep (10)
WEnd
Sleep (10)
EndIf
WEnd
AdlibEnable ( "_main" , $game_speed )
ExitLoop
EndIf
$msg = 0
EndIf
Sleep (10)
WEnd
GUIDelete ()
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit]Func _info_button ()
$msg = @GUI_CtrlId
Return 0
EndFunc
Func _zeichnen ()
_GDIPlus_GraphicsClear($Buffer[0],0xFFFFFFFF)
_GDIPlus_GraphicsDrawImage ($Buffer[0],$background,0,0)
; _GDIPlus_GraphicsDrawPie ($Buffer,$x[0] - 32,$y[0] - 32,64,64,0 - $Rotate[0] - 90,360,$hPen)
; _GDIPlus_GraphicsDrawPie ($Buffer,$x[1] - 32,$y[1] - 32,64,64,0 - $Rotate[1] - 90,360,$hPen2)
_GDIPlus_GraphicsFillEllipse($Buffer[0], $ball_x - $ball_radius, $ball_y - $ball_radius, $ball_radius * 2, $ball_radius * 2, $hBrush[0])
_GDIPlus_GraphicsDrawStringColor($Buffer[0], $player[0], $x[0] - 32, $y[0] - 56, "Ellis", 10, 0, 0xFF0000FF)
_GDIPlus_GraphicsDrawStringColor($Buffer[0], $player[1], $x[1] - 32, $y[1] - 56, "Ellis", 10, 0, 0xFFFF0000)
; _GDIPlus_GraphicsDrawString ($Buffer,$player[0],$x - 32,$y - 32 - 24,"Ellis")
; _GDIPlus_GraphicsDrawString ($Buffer,$player[1],$x2 - 32,$y2 - 32 - 24,"Ellis")
_GDIPlus_GraphicsDrawStringColor($Buffer[0], $player_score[0] , 280, 5, "Ellis", 20, 0, 0xFF0000FF)
_GDIPlus_GraphicsDrawStringColor($Buffer[0], $player_score[1] , 350, 5, "Ellis", 20, 0, 0xFFFF0000)
; _GDIPlus_GraphicsDrawString ($Buffer,$player_score[0],100,5,"Ellis",20)
; _GDIPlus_GraphicsDrawString ($Buffer,$player_score[1],500,5,"Ellis",20)
_gdiplus_matrix_draw_xy_degree ($x[0],$y[0],$rotate[0],0)
_gdiplus_matrix_draw_xy_degree ($x[1],$y[1],$rotate[1],1)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $Bitmap,0,0, $width, $height)
EndFunc
Func _gdiplus_matrix_draw_xy_degree ($ix,$iy,$irotate,$ii)
_GDIPlus_MatrixDispose ($hMatrix)
$hMatrix = _GDIPlus_MatrixCreate()
_GDIPlus_MatrixTranslate($hMatrix, $ix, $iy)
_GDIPlus_MatrixRotate($hMatrix,-$irotate + 90, "False")
_GDIPlus_GraphicsSetTransform($Buffer[1], $hMatrix)
_GDIPlus_GraphicsDrawImage($Buffer[1], $hImage, -$iWidth / 2 , -$iHeight / 2)
EndFunc
Func _bot ()
Local $info[3], $m, $t
$m = $rotate[1]
$c = Sqrt (($ball_x ) ^ 2 + ($ball_y - 200) ^ 2)
$var1 = ($ball_x) / $c
$info[0] = ACos ($var1) * $radToDeg
If 200 > $ball_y Then $info[0] = -$info[0]
$info[0] -= 90
$c = Sqrt (($x[1]) ^ 2 + ($y[1] - 200) ^ 2)
$var1 = ($x[1]) / $c
$info[1] = ACos ($var1) * $radToDeg
If 200 > $y[1] Then $info[1] = -$info[1]
$info[1] -= 90
$c = Sqrt (($ball_x - $x[1]) ^ 2 + ($ball_y - $y[1]) ^ 2) ;C = Wurzel (A^2+B^2), erst wird Ball_x bzw y von x bzw y subtrahiert.
$var1 = ($ball_x - $x[1]) / $c ; Verhältnis zwischen a und c zur anschließenden ACos berechtung
$info[2] = ACos ($var1) * $radToDeg
If $ball_y > $y[1] Then $info[2] = -$info[2]
$info[2] -= 90
; ToolTip ("Ball & Tor: " & Int ($info[0]) & " " & "Auto & Tor: " & Int ($info[1]) & " " & "Auto & Ball: " & Int ($rotate[1]))
If _IsPressed (1) Then
$t = MouseGetPos ()
$ball_x = $t[0]
$ball_y = $t[1] - 32
$ball_schwung = 0
EndIf
If $c > 100 Then
If $c > 300 Then $schwung[1] -= 0.05
$schwung[1] -= 0.025
$rotate[1] = $info[2]
Else
If $schwung[1] < -4 Then $schwung[1] += 0.5
[/autoit] [autoit][/autoit] [autoit]If $info[0] < $info[1] Then
If $rotate[1] < -0 Then $rotate[1] += 5
If $rotate[1] > 0 Then $rotate[1] -= 5
Else
If $rotate[1] < 180 Then $rotate[1] += 5
If $rotate[1] > 180 Then $rotate[1] -= 5
EndIf
If $rotate[1] > 175 And $rotate[1] < 185 Then $rotate[1] = 180
If $rotate[1] > -5 And $rotate[1] < 5 Then $rotate[1] = 0
If Int ($info[0]) <> Int ($info[1]) Then
If $rotate[1] = 0 Or $rotate[1] = 180 Then $schwung[1] -= 0.05
Else
$rotate[1] = $info[2]
$schwung[1] -= 0.05
; If $rotate[1] < $info[2] Then $rotate[1] += 5
; If $rotate[1] > $info[2] Then $rotate[1] -= 5
; If $rotate[1] < $info[2] + 5 And $rotate[1] > $info[2] - 5 Then $rotate[1] = $info[2]
EndIf
EndIf
EndFunc
[/autoit] [autoit][/autoit] [autoit]Func _tor ($player_num)
Local $color[5] = [0xFF0000FF, 0xFF00FF00, 0xFFFF0000, 0xFFFFFF00, 0xFF00FFFF]
For $i = 0 To 10 Step 0.4
_GDIPlus_GraphicsDrawStringColor($Buffer[0], "Tor", 195 - $i * 26, 100 - $i * 16, "Ellis", 100 + $i * 16, 0, $color[Random (0,4,1)] )
_GDIPlus_GraphicsDrawImageRect($hGraphic, $Bitmap,0,0, $width, $height)
Sleep (10)
Next
Sleep (500)
$player_score[$player_num] += 1
If $player_score[$player_num] = 5 Then
MsgBox (0,"Winner",$player[$player_num] & " hat das Spiel gewonnen")
$player_score[0] = 0
$player_score[1] = 0
EndIf
$rotate_abprall[0] = 0
$rotate_abprall[1] = 0
$schwung_abprall[0] = 0
$schwung_abprall[1] = 0
$rotate[0] = 270
$x[0] = 68
$y[0] = 200
$schwung[0] = 0
$rotate[1] = 90
$x[1] = 572
$y[1] = $y[0]
$schwung[1] = 0
$ball_rotate = 0
$ball_x = 304
$ball_y = $y[0]
$ball_schwung = 8
EndFunc
Func _lan_create ()
[/autoit] [autoit][/autoit] [autoit]Local $IP, $recv
[/autoit] [autoit][/autoit] [autoit]If StringLeft ($PC_IP,7) <> "192.168" Then
$return = MsgBox (3,"Komische IP", "Ihre IP: " & $PC_IP & " scheint verstellt oder durch andere Programmme" & @CRLF & "verändert, wolle sie sie korrigieren?")
If $return = 6 Then
Do
$PC_IP = InputBox ("IP korrigieren","Bitte geben sie ihre normal Lan IP ein")
Until MsgBox (3, "IP korrigieren", "Wollen sie die IP: " & $PC_IP & " beibehalten") = 6
EndIf
EndIf
$GUI = GUICreate ("Deine IP: " & $PC_IP, 400, 150, -1, -1)
GUISetBkColor (0xFFFFFF)
$button_host = GUICtrlCreateButton ("Host ", 120,100,60,30)
GUICtrlSetBkColor (-1,0xFFFFFF)
GUICtrlSetColor (-1,0x00FF00)
GUICtrlSetFont(-1, 18, 400, 0, "Comic Sans MS")
GUICtrlSetCursor(-1, 0)
$button_join = GUICtrlCreateButton ("Join ", 200,100,60,30)
GUICtrlSetBkColor (-1,0xFFFFFF)
GUICtrlSetColor (-1,0x00FF00)
GUICtrlSetFont(-1, 18, 400, 0, "Comic Sans MS")
GUICtrlSetCursor(-1, 0)
$button_ok = GUICtrlCreateButton (" OK ",400,0,0,0)
GUICtrlSetBkColor (-1,0xFFFFFF)
GUICtrlSetColor (-1,0x00FF00)
GUICtrlSetFont(-1, 18, 400, 0, "Comic Sans MS")
GUICtrlSetCursor(-1, 0)
$info = GUICtrlCreateLabel ("Wähle eine Aktion aus",20,5,360,30)
GUICtrlSetColor (-1,0x0000FF)
GUICtrlSetFont(-1, 12, 400, 0, "Comic Sans MS")
$input_ip = GUICtrlCreateInput ("",400,0,0,0)
GUICtrlSetColor (-1,0x00FF00)
GUICtrlSetFont(-1, 18, 400, 0, "Comic Sans MS")
GUICtrlSetCursor(-1, 0)
GUISetState ()
While True
$msg = GUIGetMsg ()
If $msg = $GUI_EVENT_CLOSE Then Exit
If $msg = $button_host Then
GUICtrlSetData ($info,"Geben sie die IP ein, die der Server haben soll")
GUICtrlSetData ($input_ip,@IPAddress1)
GUICtrlSetPos ($input_ip,20,100,300,40)
GUICtrlSetPos ($button_ok,320,100,60,30)
GUICtrlSetPos ($button_join,400,0,0,0)
GUICtrlSetPos ($button_host,400,0,0,0)
While True
$msg = GUIGetMsg ()
If $msg = $GUI_EVENT_CLOSE Then Exit
If $msg = $button_ok Then
$ip = GUICtrlRead ($input_ip)
GUICtrlSetData ($info,"Der Server wird nun erstellt...")
GUICtrlSetPos ($button_ok,400,0,0,0)
GUICtrlSetPos ($input_ip,400,0,0,0)
GUICtrlSetPos ($info,20,50,360,60)
_server("host",$IP)
If $error = 1 Then ExitLoop
ExitLoop 2
EndIf
WEnd
ElseIf $msg = $button_join Then
GUICtrlSetData ($info,"Geben sie die IP des Servers ein ")
GUICtrlSetPos ($input_ip,20,100,300,40)
GUICtrlSetPos ($button_ok,320,100,60,30)
GUICtrlSetPos ($button_join,400,0,0,0)
GUICtrlSetPos ($button_host,400,0,0,0)
While True
$msg = GUIGetMsg ()
If $msg = $GUI_EVENT_CLOSE Then Exit
If $msg = $button_ok Then
$ip = GUICtrlRead ($input_ip)
GUICtrlSetData ($info,"Es wird versucht ein Verbindung herzustellen...")
GUICtrlSetPos ($button_ok,400,0,0,0)
GUICtrlSetPos ($input_ip,400,0,0,0)
GUICtrlSetPos ($info,20,50,360,60)
_server("join",$IP)
If $error = 1 Then ExitLoop
ExitLoop 2
EndIf
WEnd
EndIf
WEnd
GUICtrlSetData ($info,"")
GUICtrlSetData ($input_ip,"")
GUICtrlSetData ($button_ok," Send ")
GUICtrlSetPos ($info,20,5,360,90)
GUICtrlSetPos ($input_ip,20,100,300,40)
GUICtrlSetPos ($button_ok,320,100,60,30)
While True
$msg = GUIGetMsg ()
If $msg = $GUI_EVENT_CLOSE Then Exit
If $msg = $button_ok Then
$text[0] = GUICtrlRead ($input_ip)
GUICtrlSetData ($input_ip,"")
TCPSend($ConnectedSocket_join, $text[0])
EndIf
$text[1] = TCPRecv($ConnectedSocket_host, 2048)
If $text[1] <> "" Then
; $text[2] = $text[2] & @CRLF & $text[1]
GUICtrlSetData ($info, $text[1])
EndIf
WEnd
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit]Func _server ($job,$IP)
Local $ip_anderer
$error = 0
TCPStartup()
If $job = "host" Then
$ip_anderer = _host ($IP, 33891)
If $error = 1 Then Return 0
GUICtrlSetData ($info,"Die Verbindung zu " & $ip_anderer & " steht")
Sleep (500)
GUICtrlSetData ($info,"IP Adressen werden nun ausgetauscht")
_join ($ip_anderer, 33890)
GUICtrlSetData ($info,"Server wurde erfolgreich erstellt")
ElseIf $job = "join" Then
_join ($IP, 33891)
GUICtrlSetData ($info,"IP Adressen werden nun ausgetauscht")
$ip_anderer = _host ($PC_IP, 33890)
If $error = 1 Then Return 0
GUICtrlSetData ($info,"Die Verbindung zu " & $IP & " steht")
EndIf
EndFunc
Func _host ($host_ip, $host_port)
Local $socket, $recv
$Socket = TCPListen($host_ip, $host_port)
If $Socket = -1 Then
GUICtrlSetData ($info,"Ein Fehler bei der Erstellung des Servers ist aufgetreten!")
Sleep (1000)
GUICtrlSetData ($info,"Wähle eine Aktion aus")
GUICtrlSetPos ($button_host, 120,100,60,30)
GUICtrlSetPos ($button_join, 200,100,60,30)
GUICtrlSetPos ($info,20,5,360,60)
$error = 1
Return 0
EndIf
Do
$ConnectedSocket_host = TCPAccept($Socket)
Until $ConnectedSocket_host <> -1
Do
$recv = TCPRecv($ConnectedSocket_host, 2048)
Until $recv <> ""
Return $recv
EndFunc
Func _join ($join_ip, $join_port)
Local $socket, $recv
$ConnectedSocket_join = TCPConnect($join_ip, $join_port)
TCPSend($ConnectedSocket_join, $PC_IP)
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit]Func _GDIPlus_GraphicsDrawStringColor($hGraphics, $sString, $nX, $nY, $sFont = "Arial", $nSize = 10, $iFormat = 0, $iBrush = 0xFF000000)
Local $hBrush, $iError, $hFamily, $hFont, $hFormat, $aInfo, $tLayout, $bResult
$hBrush = _GDIPlus_BrushCreateSolid($iBrush)
$hFormat = _GDIPlus_StringFormatCreate($iFormat)
$hFamily = _GDIPlus_FontFamilyCreate($sFont)
$hFont = _GDIPlus_FontCreate($hFamily, $nSize)
$tLayout = _GDIPlus_RectFCreate($nX, $nY, 0, 0)
$aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sString, $hFont, $tLayout, $hFormat)
$bResult = _GDIPlus_GraphicsDrawStringEx($hGraphics, $sString, $hFont, $aInfo[0], $hFormat, $hBrush)
$iError = @error
_GDIPlus_FontDispose($hFont)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_StringFormatDispose($hFormat)
_GDIPlus_BrushDispose($hBrush)
Return SetError($iError, 0, $bResult)
EndFunc ; ==> String in Farbe zeichnen
Func _testversion_check ()
Local $iDateCalc = _DateDiff( 's',$Testversion,_NowCalc())
If $iDateCalc > 0 Then
MsgBox (0,"","Die Test-Version von " & $Titel & " ist abgelaufen!")
Exit
EndIf
EndFunc ; ==> Prüft ob die Version aktuell ist
[/autoit] [autoit][/autoit] [autoit]Func _beenden ()
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_GraphicsDispose ($hGraphic)
_GDIPlus_BitmapDispose ($Bitmap)
_GDIPlus_GraphicsDispose ($Buffer[0])
_GDIPlus_GraphicsDispose ($Buffer[1])
_GDIPlus_ImageDispose ($background)
_GDIPlus_BrushDispose ($hBrush[0])
_GDIPlus_Shutdown ()
_SoundClose ($sound_schuss)
; DllClose ($dll)
Exit
EndFunc