Hallo,
heute darf ich euch mein Minigame Lights out präsentieren. Es geht darum, so schnell wie möglich alle Lichter auszuknipsen.
Das Ergebnis kann man dann mit dem seienr Freunde und Kollegen vergleichen.
Hier die Source:
Spoiler anzeigen
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=F:\Fertige Programme\Lights out\Lights out.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include<array.au3>
#include<listviewconstants.au3>
#include<guilistview.au3>
#include<gdiplus.au3>
#include<staticconstants.au3>
local $ar[41]
global $i= random(1, 40)
global $counter=0
global $gerundet=0
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Lights out", 500, 600, 192, 124)
$knopf1 = GUICtrlCreateButton("Start", 23, 25, 57, 33, $WS_GROUP)
$ar[1]= GUICtrlCreateButton("", 24, 64, 57, 57, $WS_GROUP)
$ar[2]= GUICtrlCreateButton("", 82, 64, 57, 57, $WS_GROUP)
$ar[3]= GUICtrlCreateButton("", 142, 64, 57, 57, $WS_GROUP)
$ar[4]= GUICtrlCreateButton("", 203, 64, 57, 57, $WS_GROUP)
$ar[5]= GUICtrlCreateButton("", 264, 64, 57, 57, $WS_GROUP)
$ar[6]= GUICtrlCreateButton("", 24, 125, 57, 57, $WS_GROUP)
$ar[7]= GUICtrlCreateButton("", 82, 125, 57, 57, $WS_GROUP)
$ar[8]= GUICtrlCreateButton("", 142, 125, 57, 57, $WS_GROUP)
$ar[9]= GUICtrlCreateButton("", 203, 125, 57, 57, $WS_GROUP)
$ar[10]= GUICtrlCreateButton("", 264, 125, 57, 57, $WS_GROUP)
$ar[11]= GUICtrlCreateButton("", 25, 185, 57, 57, $WS_GROUP)
$ar[12]= GUICtrlCreateButton("", 83, 185, 57, 57, $WS_GROUP)
$ar[13]= GUICtrlCreateButton("", 143, 185, 57, 57, $WS_GROUP)
$ar[14]= GUICtrlCreateButton("", 204, 185, 57, 57, $WS_GROUP)
$ar[15]= GUICtrlCreateButton("", 265, 185, 57, 57, $WS_GROUP)
$ar[16]= GUICtrlCreateButton("", 25, 246, 57, 57, $WS_GROUP)
$ar[17]= GUICtrlCreateButton("", 83, 246, 57, 57, $WS_GROUP)
$ar[18]= GUICtrlCreateButton("", 143, 246, 57, 57, $WS_GROUP)
$ar[19]= GUICtrlCreateButton("", 204, 246, 57, 57, $WS_GROUP)
$ar[20]= GUICtrlCreateButton("", 265, 246, 57, 57, $WS_GROUP)
$ar[21]= GUICtrlCreateButton("", 27, 306, 57, 57, $WS_GROUP)
$ar[22]= GUICtrlCreateButton("", 85, 306, 57, 57, $WS_GROUP)
$ar[23]= GUICtrlCreateButton("", 145, 306, 57, 57, $WS_GROUP)
$ar[24]= GUICtrlCreateButton("", 206, 306, 57, 57, $WS_GROUP)
$ar[25]= GUICtrlCreateButton("", 267, 306, 57, 57, $WS_GROUP)
$ar[26]= GUICtrlCreateButton("", 27, 367, 57, 57, $WS_GROUP)
$ar[27]= GUICtrlCreateButton("", 85, 367, 57, 57, $WS_GROUP)
$ar[28]= GUICtrlCreateButton("", 145, 367, 57, 57, $WS_GROUP)
$ar[29]= GUICtrlCreateButton("", 206, 367, 57, 57, $WS_GROUP)
$ar[30]= GUICtrlCreateButton("", 267, 367, 57, 57, $WS_GROUP)
$ar[31]= GUICtrlCreateButton("", 27, 429, 57, 57, $WS_GROUP)
$ar[32]= GUICtrlCreateButton("", 85, 429, 57, 57, $WS_GROUP)
$ar[33]= GUICtrlCreateButton("", 145, 429, 57, 57, $WS_GROUP)
$ar[34]= GUICtrlCreateButton("", 206, 429, 57, 57, $WS_GROUP)
$ar[35]= GUICtrlCreateButton("", 267, 429, 57, 57, $WS_GROUP)
$ar[36]= GUICtrlCreateButton("", 27, 490, 57, 57, $WS_GROUP)
$ar[37]= GUICtrlCreateButton("", 85, 490, 57, 57, $WS_GROUP)
$ar[38]= GUICtrlCreateButton("", 145, 490, 57, 57, $WS_GROUP)
$ar[39]= GUICtrlCreateButton("", 206, 490, 57, 57, $WS_GROUP)
$ar[40]= GUICtrlCreateButton("", 267, 490, 57, 57, $WS_GROUP)
For $p= 1 to 40
guictrlsetstate($ar[$p], $gui_disable)
guictrlsetbkcolor($ar[$p], 0x000000)
next
$Button1 = GUICtrlCreateButton("In die Highscore eintragen", 323, 25, 133, 32, $WS_GROUP)
$ListView1 = GUICtrlCreateListView("Name des Spielers|Zeit", 323, 65, 240, 241)
Global $B_DESCENDING[_GUICtrlListView_GetColumnCount($ListView1)]
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 110)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 60)
guictrlsetbkcolor($listview1, 0x000000)
guictrlsetcolor($listview1, 0xFFFFFF)
$iniread= IniReadSectionNames(@Scriptdir&"\score.ini")
$armax=_ArrayMax($iniread)
For $a=1 to $armax
guictrlcreatelistviewitem($iniread[$a]&"|"& Iniread(@scriptdir&"\score.ini", $iniread[$a], "1name", ""), $listview1)
next
_GUICtrlListView_SimpleSort($listview1, $B_DESCENDING[1], 1)
soundplay(@Scriptdir&"\st.mp3",0 )
$Pic1 = GUICtrlCreatePic(@Scriptdir&"\matrix.jpg", 0, 1, 500, 600, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
case $GUI_EVENT_CLOSE
Exit
case $knopf1
For $p= 1 to 40
guictrlsetstate($ar[$p], $gui_enable)
next
$time= Timerinit()
guictrlsetstate($knopf1, $gui_disable)
$i= random(1, 40)
guictrlsetbkcolor($ar[$i], 0x57FF5C)
case $ar[$i]
$counter+=1
If $counter=50 then
For $p= 1 to 40
guictrlsetstate($ar[$p], $gui_disable)
next
guictrlsetstate($button1, $gui_enable)
$ungerundet=Timerdiff($time)* 10^(-3)
$gerundet= StringFormat("%.2f\n", $ungerundet )
Msgbox(0, "", "Du hast"& $gerundet & "Sekunden gebraucht, um alle Lichter auszuknipsen" )
$counter=0
guictrlsetbkcolor($ar[$i], 0xFFFFFF)
guictrlsetstate($knopf1, $gui_enable)
else
guictrlsetbkcolor($ar[$i], 0xFFFFFF)
$i= random(1, 40)
guictrlsetbkcolor($ar[$i], 0x57FF5C)
endif
case $button1
If $gerundet=0 then
msgbox(0, "Fehler", "Du hast noch nicht gespielt")
Else
GUICtrlSetState($button1, $gui_disable)
$input= Inputbox("Dein Name", "Wie ist dein Name?")
If $input<> 0 and $input<> 1 and $input<> 2 and $input<> 3 and $input<> 4 and $input<> 5 and $input<>6 and $input<> 7 and $input<> 8 and $input<> 9 Then
Msgbox(0, "Fehler", "Dein Name darf keine Zahlen beeinhalten")
else
$name= Iniwrite(@ScriptDir&"\score.ini", $input, "1name", $gerundet)
$iniread= IniReadSectionNames(@Scriptdir&"\score.ini")
$armax=_ArrayMax($iniread)
_GUICtrlListView_DeleteAllItems($listview1)
For $j=1 to $armax
guictrlcreatelistviewitem($iniread[$j]&"|"& Iniread(@scriptdir&"\score.ini", $iniread[$j], "1name", ""), $listview1)
next
_GUICtrlListView_SimpleSort($listview1, $B_DESCENDING[1],1)
endif
endif
EndSwitch
wend
Der Downloadlink: http://www.file-upload.net/download-31436…ts-out.rar.html
Mit dabei ist ne ini, die eigentlich ohnehin erstellt wird^^
- der Matrixhintergrund
- und ein kleiner Soundtrack.
Viel Spaß beim Ausprobieren
Edit1: Kleiner Fehler bemerkt, wird morgen behoben.