Mine v0.2!

« Older   Newer »
  Share  
xMasteRx
CAT_IMG Posted on 22/7/2010, 22:47     +1   -1




Beh, mentre non avevo niente da fare nel pc nč in nessun altro posto, ho incominciato a giocare mine e allora mi č venuta volonta di farne uno XD
PS: Caso nn vedete le immagini delle bombe, ho lasciato nel codice i comandi per cambiarne il colore invece di creare l'immagine, basta che lo leggete un po e capirete ;D
PS²: Chi se lo spaccia per suo brucierą per l'eternitą nell'inferno, :ph34r:
LOL

MINE v0.3
Aggiornamenti:

  1. - Timer pił preciso

  2. - Il timer inizia soltanto dopo sia premuta il primo pulsante



MINE v0.5
Aggiornamenti:

  1. - Pausa quando il focus non é sul gioco

  2. - Ridimensionare la finestra comporta il suo intero aggiornamento delle posizioni e misure



image

SOURCE: (AGGIORNATO ALLA V0.5)
SPOILER (click to view)
CODICE
#include<GUIConstantsEx.au3>
#include<ButtonConstants.au3>
#include<WindowsConstants.au3>
$s=0
$fatorX=30
$fatorY=30
If Not FileExists("bomba_ico.bmp") Then
       ToolTip("Downloading files! 0%")
       InetGet("http://mastersoft.altervista.org/bomba_ico.bmp", "bomba_ico.bmp")
       ToolTip("Downloading files! 50%")
       InetGet("http://mastersoft.altervista.org/1bomba.bmp", "1bomba.bmp")
       ToolTip("Downloading files! 100%")
       Sleep(500)
       ToolTip("")
EndIf
$WW=InputBox("Mine", "Set the width of the game", 30)
If @error Then Exit
$WH=InputBox("Mine", "Set the height of the game", 16)
If @error Then Exit
$PX=InputBox("Mine", "Set how many mines the game will have", 99)
If @error Then Exit
Do
       $LOOSE=False
       ToolTip("Randomised table database construction...")
       $LX=$WH*$WW-$PX+1
       $MINEPOS=""
       $SEC=$PX
       $OKP=$WW*$WH-$PX
       $Time=0
       Opt("GUIOnEventMode", 1)
       Global $pos[$PX+1][2], $BUT[$WW+1][$WH+1][4], $COUNTER[$WW+1][$WH+1]
       $GUI=GUICreate("Mines", $WW*$fatorX+20, $WH*$fatorY+80, -1, -1, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX))
       GUISetOnEvent($GUI_EVENT_RESIZED, "_GUIResize")
       GUISetState()
       $LAB=GUICtrlCreateLabel("Mines: "&$SEC&@TAB&"Time: 0 sec"&@TAB&"By MasteR(CaiO)", 10, $WH*$fatorY+15, $WW*$fatorX+10, 20)
       GUICtrlSetFont(-1, 14)
       GUICtrlSetColor(-1, 0x00CFFF)
       GUISetOnEvent(-3, "_Exit")
       GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, "_SecDown")
       For $n=0 To $PX-1
               $pos[$n][0]=Random(1, $WW, 1)
               $pos[$n][1]=Random(1, $WH, 1)
               For $i=0 To $PX-1
                       If $pos[$n][0]=$pos[$i][0] And $pos[$n][1]=$pos[$i][1] And $i<>$n Then
                               $R=True
                               $n-=1
                               ExitLoop
                       EndIf
                       $R=False
               Next
               If $R=False Then
                       $MINEPOS&="("&$pos[$n][0]&","&$pos[$n][1]&")"
                       $BUT[$pos[$n][0]][$pos[$n][1]][0]=GUICtrlCreateButton("", $pos[$n][0]*$fatorX+10-$fatorX, $pos[$n][1]*$fatorY+10-$fatorY, $fatorX, $fatorY, $BS_BITMAP)
                       GUICtrlSetResizing(-1, 904)
                       GUICtrlSetFont(-1, $fatorX/1.6, -1, -1, "Arial")
                       GUICtrlSetOnEvent(-1, "_BombPress")
                       ;GUICtrlSetBkColor(-1, 0)
               EndIf
       Next
       ConsoleWrite("Done;"&@CRLF)
       $n=0
       For $x=1 To $WW
               For $y=1 To $WH
                       If Not StringInStr($MINEPOS, "("&$x&","&$y&")") Then
                               $BUT[$x][$y][1]=GUICtrlCreateButton("", $x*$fatorX+10-$fatorX, $y*$fatorY+10-$fatorY, $fatorX, $fatorY, $BS_BITMAP)
                               GUICtrlSetFont(-1, $fatorX/1.6, -1, -1, "Arial")
                               GUICtrlSetResizing(-1, 904)
                               $BUT[$x][$y][2]=$x
                               $BUT[$x][$y][3]=$y
                               GUICtrlSetOnEvent(-1, "_OkPress")
                               $n+=1
                       EndIf
               Next
       Next
       Sleep(200)
       ToolTip("")
       Do
               Sleep(100)
               If WinGetTitle("[ACTIVE]")<>"Mines" Then
                       AdlibUnRegister("_TimeAdd")
                       For $x=0 To $WW
                               For $y=0 To $WH
                                       GUICtrlSetState($BUT[$x][$y][0], $GUI_HIDE)
                                       GUICtrlSetState($BUT[$x][$y][1], $GUI_HIDE)
                               Next
                       Next
                       $PLAB=GUICtrlCreateLabel("PAUSED", 0, 0, $WW*$fatorX, $WH*$fatorY)
                       GUICtrlSetFont($PLAB, ($WW*$fatorX)/6.5)
                       Do
                               Sleep(200)
                       Until WinGetTitle("[ACTIVE]")="Mines"
                       GUICtrlDelete($PLAB)
                       For $x=0 To $WW
                               For $y=0 To $WH
                                       GUICtrlSetState($BUT[$x][$y][0], $GUI_SHOW)
                                       GUICtrlSetState($BUT[$x][$y][1], $GUI_SHOW)
                               Next
                       Next
                       AdlibRegister("_TimeAdd", 99)
               EndIf
               If $SEC=0 And $OKP=0 Or $LOOSE Then ExitLoop
       Until 1=2
       If Not $LOOSE Then
               If MsgBox(52, "Mines", "You win! Restart?", 960, $GUI)=7 Then Exit                        
               GUIDelete()
       Else
               If MsgBox(20, "Mines", "You loose! Restart?", 960, $GUI)=7 Then Exit
               GUIDelete()
       EndIf
       AdlibUnRegister("_TimeAdd")
Until 1=2

Func _GUIResize()
       $WPOS=WinGetPos("Mines")
       $fatorX=Round((($WPOS[2]-20)/$WW)-0.2, 2)
       $fatorY=Round((($WPOS[3]-80)/$WH)-(0.2+0.18), 2)
       ConsoleWrite($fatorX&@TAB&$WPOS[2]&@CRLF&$fatorY&@TAB&$WPOS[3]&@CRLF)
       For $x=0 To $WW
               For $y=0 To $WH
                       GUICtrlSetPos($BUT[$x][$y][0], $x*$fatorX+10-$fatorX, $y*$fatorY+10-$fatorY, $fatorX, $fatorY)
                       GUICtrlSetPos($BUT[$x][$y][1], $x*$fatorX+10-$fatorX, $y*$fatorY+10-$fatorY, $fatorX, $fatorY)
               Next
       Next
       GUICtrlSetPos($LAB,10, $WH*$fatorY+15, $WW*$fatorX+10, 20)
EndFunc

Func _SecDown()
       AdlibRegister("_TimeAdd", 99)
       $MINFO=GUIGetCursorInfo()
       If GUICtrlRead($MINFO[4])<>"X" Then
               GUICtrlSetData($MINFO[4], "X")
               GUICtrlSetColor($MINFO[4], 0xFFFF00)
               GUICtrlSetBkColor($MINFO[4], 0x00C000)
               $SEC-=1
       ElseIf GUICtrlRead($MINFO[4])="X" Then
               GUICtrlSetData($MINFO[4], "")
               $SEC+=1
       EndIf
EndFunc

Func _BombPress()
       $ButPress=@GUI_CtrlId
       If GUICtrlRead($ButPress)<>"" Then Return -1
       For $x=0 To $WW
               For $y=0 To $WH
                       If GUICtrlRead($BUT[$x][$y][0])="" Then
                               ;GUICtrlSetBkColor($BUT[$x][$y][0], 0xFF0000)
                               GUICtrlSetImage($BUT[$x][$y][0], "bomba_ico.bmp")
                       Else
                               ;GUICtrlSetBkColor($BUT[$x][$y][0], 0x0FF0FF)
                               GUICtrlSetImage($BUT[$x][$y][0], "bomba_ico.bmp")
                       EndIf
                       If GUICtrlRead($BUT[$x][$y][0])="X" Then
                               GUICtrlSetData($BUT[$x][$y][0], "OK")
                               GUICtrlSetBkColor($BUT[$x][$y][0], 0xFF0FF0)
                       EndIf
               Next
       Next
       For $x=0 To $WW
               For $y=0 To $WH
                       If GUICtrlRead($BUT[$x][$y][1])="" Then
                               GUICtrlSetBkColor($BUT[$x][$y][1], 0x00C000)
                       Else
                               GUICtrlSetBkColor($BUT[$x][$y][1], 0x00FFFF)
                       EndIf
                       If GUICtrlRead($BUT[$x][$y][1])="X" And $BUT[$x][$y][1]<>"" Then
                               GUICtrlSetBkColor($BUT[$x][$y][1], 0x000000)
                               GUICtrlSetData($BUT[$x][$y][0], "FAIL")
                       EndIf
               Next
       Next
       ;GUICtrlSetBkColor($ButPress, 0x0000FF)
       ;GUICtrlSetData($ButPress, "FAIL")
       GUICtrlSetImage($ButPress, "1bomba.bmp")
       $LOOSE=True
EndFunc

Func _OkPress($x=-1, $y=-1)
       AdlibRegister("_TimeAdd", 99)
       If $x<0 Or $y<0 Or $x>UBound($BUT, 1)-1 Or $y>UBound($BUT, 2)-1 Then
               $ButPress=@GUI_CtrlId
               For $x=0 To $WW
                       For $y=0 To $WH
                               If $ButPress=$BUT[$x][$y][1] Then ExitLoop 2
                       Next
               Next
       EndIf
       If GUICtrlRead($BUT[$x][$y][1])<>"" Or $BUT[$x][$y][1]="" Or GUICtrlRead($BUT[$x][$y][1])="X" Then Return -1
       $OKP-=1
       GUICtrlSetBkColor($BUT[$x][$y][1], 0xFFFFBB)
       $COUNTER[$x][$y]=0
       For $Nx=-1 To 1
               For $Ny=-1 To 1
                       If Not ($Nx=0 And $Ny=0) Then
                               If $x+$Nx>0 And $x+$Nx<=$WW And $y+$Ny>0 And $y+$Ny<=$WH And $BUT[$x+$Nx][$y+$Ny][0]<>"" Then $COUNTER[$x][$y]+=1
                       EndIf
               Next
       Next
       GUICtrlSetData($BUT[$x][$y][1], $COUNTER[$x][$y])
       If $COUNTER[$x][$y]=0 Then GUICtrlSetData($BUT[$x][$y][1], "   ")
       If $COUNTER[$x][$y]=1 Then GUICtrlSetColor($BUT[$x][$y][1], 0x4040FF)
       If $COUNTER[$x][$y]=2 Then GUICtrlSetColor($BUT[$x][$y][1], 0x00AA00)
       If $COUNTER[$x][$y]=3 Then GUICtrlSetColor($BUT[$x][$y][1], 0xFF0000)
       If $COUNTER[$x][$y]=4 Then GUICtrlSetColor($BUT[$x][$y][1], 0xFF20FF)
       If $COUNTER[$x][$y]=5 Then GUICtrlSetColor($BUT[$x][$y][1], 0x00FFFF)
       If $COUNTER[$x][$y]=6 Then GUICtrlSetColor($BUT[$x][$y][1], 0x00CC00)
       If $COUNTER[$x][$y]=7 Then GUICtrlSetColor($BUT[$x][$y][1], 0xAAAA00)
       If $COUNTER[$x][$y]=8 Then GUICtrlSetColor($BUT[$x][$y][1], 0xAA00FF)
       If $COUNTER[$x][$y]=0 Then
               GUICtrlSetColor($BUT[$x][$y][1], 0x0000FF)
               For $NX=-1 To 1
                       For $NY=-1 To 1
                               If $x+$NX>0 And $x+$NX<=$WW And $y+$NY>0 And $y+$NY<=$WH And $BUT[$x+$NX][$y+$NY][0]="" And GUICtrlRead($BUT[$x+$NX][$y+$NY][1])="" Then _OkPress($x+$NX, $y+$NY)
                       Next
               Next
       EndIf
EndFunc

Func _TimeAdd()
       $Time+=10
       GUICtrlSetData($LAB, "Mines: "&$sec&@TAB&"Time: "&Round($Time/100)&" sec"&@TAB&"By MasteR(CaiO)")
EndFunc

Func _Exit()
       If MsgBox(36, "Mines", "Are you sure?", 960, $GUI)<>7 Then Exit
EndFunc


COMPILATO (AGGIORNATO ALLA V0.5)
http://mastersoft.altervista.org/Mine.exe

Edited by xMasteRx - 26/7/2010, 01:03
 
Top
ACIDBURN16
CAT_IMG Posted on 22/7/2010, 23:05     +1   -1




Molto bello!! bravo!
 
Top
xMasteRx
CAT_IMG Posted on 22/7/2010, 23:09     +1   -1




Grazie, (:
Qualsiasi bug o suggerimento ditemelo che lo faccio, questo script devo ammetterlo mi č venuto piuttosto bene, (:
 
Top
Gianlu-thebest
CAT_IMG Posted on 23/7/2010, 00:39     +1   -1




Bellissimo! Bravo!
 
Top
Lahace
CAT_IMG Posted on 23/7/2010, 08:41     +1   -1




bello sisi peccato che io non sappia giocarci xD
 
Top
lollofieretto
CAT_IMG Posted on 23/7/2010, 08:44     +1   -1




bello veramente =)
 
Top
bradipooso
CAT_IMG Posted on 23/7/2010, 10:21     +1   -1




ingegnoso!
 
Top
xMasteRx
CAT_IMG Posted on 24/7/2010, 06:07     +1   -1




thanks! ;D
beh.. giocare a mine non č cosi difficile dai l'o imparato quand'ero piccino LOL
 
Top
erma96
CAT_IMG Posted on 24/7/2010, 09:35     +1   -1




Un consigio: fai partire il timer appena il giocatore preme sulla prima casella della partita, perchč se no il reale tempo impiegato viene alterato.
 
Top
Kn0t
CAT_IMG Posted on 25/7/2010, 19:40     +1   -1




CITAZIONE (erma96 @ 24/7/2010, 10:35)
Un consigio: fai partire il timer appena il giocatore preme sulla prima casella della partita, perchč se no il reale tempo impiegato viene alterato.

Quoto, per il resto g00d w0rk.
 
Top
xMasteRx
CAT_IMG Posted on 25/7/2010, 21:52     +1   -1




Lanciata la v0.3 :D
 
Top
ACIDBURN16
CAT_IMG Posted on 25/7/2010, 22:43     +1   -1




Molto Bello + 1 :D
 
Top
xMasteRx
CAT_IMG Posted on 26/7/2010, 00:04     +1   -1




Rilasciata v0.5
Credo che ormai non ci sia quasi niente da fare qui, XD
Anche se lo credo cosķ, date le vostre idee, pareri e i bug
 
Top
Kn0t
CAT_IMG Posted on 26/7/2010, 10:54     +1   -1




Ottimo!
 
Top
13 replies since 22/7/2010, 22:47   406 views
  Share