Vorgestern gab es in der Shoutbox den Vorschlag, diesen Test nachzumachen. Auch wenn es nicht an mich gerichtet war, hab ich es trotzdem mal gemacht.
Spoiler anzeigen
; In Anlehnung an http://www.msf-longkamp.de/pilotentest.html
#AutoIt3Wrapper_usex64=n
#region includes
#include <QuickDraw.au3>
#include <Array.au3>
#include <Misc.au3>
#endregion includes
#region Variablen und Einstellungen
HotKeySet("{NUMPADSUB}", "changeSpeed")
HotKeySet("{NUMPADADD}", "changeSpeed")
Opt("MouseCoordMode", 2)
Dim $rects[4][6] = [[30, 30, 170, 30, Random(-5, 5, 1), Random(-5, 5, 1)],[400, 30, 50, 170, Random(-5, 5, 1), Random(-5, 5, 1)], _
[300, 400, 153, 30, Random(-5, 5, 1), Random(-5, 5, 1)],[32, 300, 50, 133, Random(-5, 5, 1), Random(-5, 5, 1)]], _
$DrawWall[4][5] = [[0, 0, 25, 500, 4],[0, 0, 500, 25, 5],[475, 0, 25, 500, 4],[0, 475, 500, 25, 5]], _
$playerRect[4] = [250, 250, 50, 50], $wall[4][5] = [[0, 0, 1, 500, 4],[0, 0, 500, 1, 5],[499, 0, 1, 500, 4],[0, 499, 500, 1, 5]]
Global $sTimer = TimerInit(), $speed = 2, $game=true, $mPressed=false
#endregion Variablen und Einstellungen
For $i = 0 To 3
If $rects[$i][4] = 0 Then $rects[$i][4] = Random(1, 5, 1)
If $rects[$i][5] = 0 Then $rects[$i][5] = Random(1, 5, 1)
Next
While true
_QuickDraw_Enable("Pilotentest", 500, 500, 500, 500, 0)
$Font = _QuickDraw_CreateFont("Arial")
For $i = 3 To 0 Step -1
counter($i)
Next
Local $cSec = @SEC, $fps = 0, $fps_zaehler = 0
$hTimer = TimerInit()
#region Hauptschleife
While _QuickDraw_Running() And Sleep(10) And $game
_QuickDraw_ClearBuffer(0xFFCCCCFF)
For $i = 0 To 3
_QuickDraw_Rect($rects[$i][0], $rects[$i][1], $rects[$i][2], $rects[$i][3], $Draw_Fill, 0xFF000099)
_QuickDraw_Rect($DrawWall[$i][0], $DrawWall[$i][1], $DrawWall[$i][2], $DrawWall[$i][3], $Draw_Fill, 0xFF000000)
Next
_QuickDraw_Text(20, 20, "Zeit: " & Round(TimerDiff($hTimer) / 1000, 3), 13, $Font, $Draw_Fill, 0xFF00FF00)
_QuickDraw_Text(100, 20, "Geschwindigkeit: " & $speed, 13, $Font, $Draw_Fill, 0xFF00FF00)
_QuickDraw_Text(280, 20, "FPS: " & $fps, 13, $Font, $Draw_Fill, 0xFF00FF00)
_QuickDraw_Rect($playerRect[0], $playerRect[1], $playerRect[2], $playerRect[3], $Draw_Fill, 0xFFFF0000)
_QuickDraw_SwapBuffers()
If TimerDiff($sTimer) > $speed * 10 Then moveBlocks()
playerRect()
FPS()
WEnd
$game=true
WEnd
#endregion Hauptschleife
#region Funktionen
Func moveBlocks()
For $i = 0 To 3
For $x = 0 To 3
If RectCollision($rects[$i][0], $rects[$i][1], $rects[$i][2], $rects[$i][3], $wall[$x][0], $wall[$x][1], $wall[$x][2], $wall[$x][3]) Then $rects[$i][$wall[$x][4]] *= (-1)
Next
$rects[$i][0] += $rects[$i][4]
$rects[$i][1] += $rects[$i][5]
Next
$sTimer = TimerInit()
EndFunc ;==>moveBlocks
Func playerRect()
$mouseX = MouseGetPos(0)
$mouseY = MouseGetPos(1)
If _IsPressed(01) And ($mouseX > $playerRect[0] - 40 And $mouseX < $playerRect[0] + 40) And ($mouseY > $playerRect[1] - 40 And $mouseY < $playerRect[1] + 40) And $mPressed=false Then
$playerRect[0] = $mouseX - $playerRect[2] / 2
$playerRect[1] = $mouseY - $playerRect[3] / 2
$mPressed=True
ElseIf _IsPressed(01) And $mPressed Then
$playerRect[0] = $mouseX - $playerRect[2] / 2
$playerRect[1] = $mouseY - $playerRect[3] / 2
Else
$mPressed=False
EndIf
For $i = 0 To 3
If RectCollision($playerRect[0], $playerRect[1], $playerRect[2], $playerRect[3], $rects[$i][0], $rects[$i][1], $rects[$i][2], $rects[$i][3]) Then end()
If RectCollision($playerRect[0], $playerRect[1], $playerRect[2], $playerRect[3], $DrawWall[$i][0], $DrawWall[$i][1], $DrawWall[$i][2], $DrawWall[$i][3]) Then end()
Next
EndFunc ;==>playerRect
Func end()
If MsgBox(4, "Verloren", "Du hast leider verloren. Du hast " & Round(TimerDiff($hTimer) / 1000, 3) & " Sekunden durchgehalten."&@CRLF&"Möchtest du es nocheinmal versuchen?")=6 Then
$game=false
WinKill("Pilotentest")
$playerRect[0]=250
$playerRect[1]=250
Dim $rects[4][6] = [[30, 30, 170, 30, Random(-5, 5, 1), Random(-5, 5, 1)],[400, 30, 50, 170, Random(-5, 5, 1), Random(-5, 5, 1)], _
[300, 400, 153, 30, Random(-5, 5, 1), Random(-5, 5, 1)],[32, 300, 50, 133, Random(-5, 5, 1), Random(-5, 5, 1)]]
For $i = 0 To 3
If $rects[$i][4] = 0 Then $rects[$i][4] = Random(1, 5, 1)
If $rects[$i][5] = 0 Then $rects[$i][5] = Random(1, 5, 1)
Next
Else
_QuickDraw_FreeFont($Font)
_QuickDraw_Disable()
Exit
EndIf
EndFunc ;==>end
Func counter($number)
For $x = 255 To 25.5 Step -25.5
_QuickDraw_ClearBuffer(0xFFCCCCFF)
For $i = 0 To 3
_QuickDraw_Rect($rects[$i][0], $rects[$i][1], $rects[$i][2], $rects[$i][3], $Draw_Fill, 0xFF000099)
_QuickDraw_Rect($DrawWall[$i][0], $DrawWall[$i][1], $DrawWall[$i][2], $DrawWall[$i][3], $Draw_Fill, 0xFF000000)
Next
_QuickDraw_Rect($playerRect[0], $playerRect[1], $playerRect[2], $playerRect[3], $Draw_Fill, 0xFFFF0000)
_QuickDraw_Rect(0, 0, 500, 500, $Draw_Fill, 0x80FFFFFF)
_QuickDraw_Text(150 + $x / 2, 250 + $x / 2, $number, $x, $Font, $Draw_Fill, "0x" & Hex($x * 1, 2) & "000000")
_QuickDraw_SwapBuffers()
Sleep(100)
Next
EndFunc ;==>counter
Func changeSpeed()
If @HotKeyPressed = "{NUMPADSUB}" Then $speed += 1
If @HotKeyPressed = "{NUMPADADD}" Then $speed -= 1
If $speed > 10 Then $speed = 10
If $speed < 0 Then $speed = 0
EndFunc ;==>changeSpeed
Func FPS()
If $cSec <> @SEC Then
$cSec = @SEC
$fps = $fps_zaehler
$fps_zaehler = 0
EndIf
$fps_zaehler += 1
EndFunc ;==>FPS
Func RectCollision($iX1, $iY1, $iWidth1, $iHeight1, $iX2, $iY2, $iWidth2, $iHeight2)
;Author: Faweyr
Return $iX1 + $iWidth1 > $iX2 And $iX1 < $iX2 + $iWidth2 And $iY1 + $iHeight1 > $iY2 And $iY1 < $iY2 + $iHeight2
EndFunc ;==>RectCollision
#endregion Funktionen
Als Zip Archiv (mit Dll, include usw.):Download Download
Mit + und - (auf dem Numpad) kann man die Geschwindigkeit verändern. Je höher der Wert, umso langsamer sind die Rechtecke.