Juego apagar las luces

y programas personales para otros como tu, puede que te corrijan ;)
Responder
Avatar de Usuario
BasicOs
Site Admin
Mensajes: 2085
Registrado: 21 Nov 2006, 19:24
Ubicación: El Internet - (Canarias, España)
Contactar:

Juego apagar las luces

Mensaje por BasicOs »

Un juego sencillo que consiste en clickar las luces verdes tan rápido como sea posible, luego te da los segundos que necesitaste.
Del foro alemán, parcialmente traducido.

Código: Seleccionar todo

#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("Empezar", 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("Meterse en los top", 323, 25, 133, 32, $WS_GROUP)
$ListView1 = GUICtrlCreateListView("NOmbre del jugador|tiempo", 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, "", "Han sido "& $gerundet & "segundos para clickar todas las luces" )
                $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, "Fallo", "Du hast noch nicht gespielt")
        Else
GUICtrlSetState($button1, $gui_disable)
$input= Inputbox("Dein Name", "Como se llama?")
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, "Fallo", "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
Fuente y créditos:
http://www.autoit.de/index.php?page=Thr ... d3bc27b864
Salu22:)
Adjuntos
borrameja.jpg
borrameja.jpg (21.2 KiB) Visto 2646 veces
Guilleqp
Mensajes: 6
Registrado: 03 Feb 2013, 14:01

Re: Juego apagar las luces

Mensaje por Guilleqp »

Esta genial el mini juego! Lo he estado probando y engancha un poco jaja Aun así he estado dando vueltas por el código y me interesa mucho la ventana de los top en la que se guarda el nombre de los jugadores y el tiempo, sin embargo no consigo entender bien ni en dónde se guardan los datos ni cómo se actualiza la tabla de tops automáticamente. Si me lo explicas un poquitin te lo agradecería :smt002

Saludosss :smt039
Avatar de Usuario
XPyro
Profesional del Autoit
Mensajes: 542
Registrado: 04 Mar 2007, 10:12
Ubicación: México
Contactar:

Re: Juego apagar las luces

Mensaje por XPyro »

Otra prueba de lo poderoso que es AutoIt, gracias por el aporte, muy entretenido :smt005
Imagen
Avatar de Usuario
BasicOs
Site Admin
Mensajes: 2085
Registrado: 21 Nov 2006, 19:24
Ubicación: El Internet - (Canarias, España)
Contactar:

Re: Juego apagar las luces

Mensaje por BasicOs »

Crea un ini, y lee del ini los nombres y puntuaciones así:

Código: Seleccionar todo

 $name= Iniwrite(@ScriptDir&"\score.ini", $input, "1name", $gerundet)
;lee el ini
$iniread= IniReadSectionNames(@Scriptdir&"\score.ini")
            $armax=_ArrayMax($iniread)
;inicializa el listview
        _GUICtrlListView_DeleteAllItems($listview1)
;añade todos los items
For $j=1 to $armax
            guictrlcreatelistviewitem($iniread[$j]&"|"& Iniread(@scriptdir&"\score.ini", $iniread[$j], "1name", ""), $listview1)
        next
;ordena
        _GUICtrlListView_SimpleSort($listview1, $B_DESCENDING[1],1)
Salu22:)
Responder