Sign in to follow this  
Followers 0
Topher

The Word Game v1.6.07

1 post in this topic

#1 ·  Posted (edited)

The Word Game is a mastermind like game in which the player tries to determine a hidden word. The word is entered by another person or chosen randomly by the game. The player then guesses using a valid word and is told how many letters in their word is in the game's word. The player has twenty chances to guess the word. Try to improve upon your average number of guesses per round.

A valid word is an uncapitalized five letter word with no repeating letters. For example: READY, CHOMP and UNZIP are valid words. SALLY, RESET and FGHYU are not.

The Dictionary

Ta Da

Instructions

Code

#NoTrayIcon
#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=backup\TWG.ico
#AutoIt3Wrapper_UseX64=n
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
;
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.6.1
Author:      Garth Bigelow
Script Function:
The Word Game
A Mastermind like game using five letter words
#ce ----------------------------------------------------------------------------
FileInstall("Dictionary.dat", "Dictionary.dat")
FileInstall("TaDa.wav", "TaDa.wav")
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <Misc.au3>
#include <WindowsConstants.au3>
Global $Name = "The Word Game"
Global $NameVersion = $Name & " ver 1.6.07" ; Always placed here so I can quickly change the version number.
Global Const $GameFile = "game.txt"
Global Const $DictionaryFile = "Dictionary.dat"
Global Const $StatFile = "Stat.txt"
Global $GameID
Global $TheWord
Global $WordArray[21]
Global $Number
Global $ShowLetters = False
;Menu Variables
Global $hWord, $hStats, $hHelp, $hMain
Global Enum $idSetWord = 1000, $idRandomWord, $idGiveUp, $idResetAlphabet, $idSaveExit, $idViewStats, $idViewStatHistory, $idResetStats, $idAbout, $idHelp
Global $MenuActionFlag = 0
;Alphabet Variables
Dim $Alphabet[27]
Dim $AlphaState[27]
Dim $LetterButtonArray[21][6]
; Mouse Variables
Global $SingleClick = False, $DoubleClick = False
Global Const $DoubleClickTime = _GetDoubleClickTime()

; Only allow one instance of the program
If _Singleton($NameVersion, 1) = 0 Then
WinActivate($NameVersion)
MsgBox(262160, "Notice", $Name & " is already running.")
Exit
EndIf
; for double clicking on letters and menu commands
GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")
; create .ini file if needed
If FileExists("Config.ini") = 0 Then
; 0 - Select via Menu
; 1 - Enter Word Always
; 2 - Random Word Always
iniWrite("Config.ini", "Word", "Always", 0)
iniWrite("Config.ini", "Color", "OutColor", 0x666666)
iniWrite("Config.ini", "Color", "OutBKColor", 0xA5D2F2)
Endif
$iniWordFlag = IniRead("Config.ini", "Word", "Always", 0)
$LetterOutColor = IniRead("Config.ini", "Color", "OutColor", 0x666666)
$LetterOutBKColor = IniRead("Config.ini", "Color", "OutBKColor", 0xA5D2F2)
; loop for games played
GUISetHelp("The Word Game.pdf")
While True
Game()
If MsgBox(262180, $Name, "Fancy another game?") = 7 Then ExitLoop
WEnd
Func Game()
$Prep = True
$Number = 1
; Create Game Window
$GameID = GUICreate($NameVersion, 800, 565, -1, -1, BitOR($WS_CAPTION, $WS_SYSMENU))
GUISetBkColor(0xA5D2F2, $GameID)
If $GameID = 0 Then ErrorBox(@ScriptLineNumber, "Platform GUI can not be created")
GUISetState()
GUISetFont(14, 600, -1, "Courier New")
SystemMenu($GameID)
GUICtrlSetState($idResetAlphabet, $GUI_DISABLE)
GetSecretWord()
; Display Alphabet Buttons
Const $Square = 790 / 26
LoadAlphaStates()
For $Letter = 1 To 26
  $Alphabet[$Letter] = GUICtrlCreateButton(Chr(64 + $Letter), $Letter * $Square - $Square + 5, 10, $Square, $Square, BitOR($BS_NOTIFY, $BS_OWNERDRAW))
  SetAlphaColor($Letter, $Alphabet[$Letter])
Next
; Create Letters Array
For $a = 1 To 20
  For $b = 1 To 5
   $LetterButtonArray[$a][$b] = GUICtrlCreateButton("", ($b - .5) * 20, 25 + ($a * 24), 20, 20, BitOR($BS_NOTIFY, $BS_OWNERDRAW))
   GUICtrlSetState($LetterButtonArray[$a][$b], $GUI_HIDE)
  Next
Next
$Number = DisplayWords()
If $Number > 1 Then _GUICtrlMenu_EnableMenuItem($hWord, 6, 0)
;Main Loop
_GUICtrlMenu_EnableMenuItem($hWord, 0, 2)
_GUICtrlMenu_EnableMenuItem($hWord, 1, 2)
_GUICtrlMenu_EnableMenuItem($hWord, 3, 0)
_GUICtrlMenu_EnableMenuItem($hWord, 5, 0)
While True
  ; End game if the 20 guesses are exhausted
  If $Number = 21 Then
   MsgBox(262192, "You Lose", "Your 20 guesses are over." & @CRLF & "My word was " & $TheWord)
   UpdateStats(-1)
   DisplayStats()
   ExitLoop
  EndIf
  $msg = GUIGetMsg()
  DetectClicks()
  If $ShowLetters = True Then
   $ShowLetters = False
   For $Letter = 1 To 26
    SetAlphaColor($Letter, $Alphabet[$Letter])
   Next
   For $Row = 1 To $Number - 1
    DisplayWord($Row)
   Next
   SaveWordFile()
   GUICtrlSetState($WordArray[$Number], $GUI_FOCUS)
  EndIf
  ; allow entry of the guess word
  If $Prep = True Then
   $WordArray[$Number] = GUICtrlCreateInput("", 20, 25 + ($Number * 24), 80, 27)
   $Guess = $WordArray[$Number]
   GUICtrlSetBkColor(-1, 0xFFFFFF)
   GUICtrlSetColor(-1, 0x000000)
   $GuessButton = GUICtrlCreateButton("Guess", 110, 25 + ($Number * 24), 80, 27)
   $Prep = False
   GUICtrlSetState($WordArray[$Number], $GUI_FOCUS)
  EndIf
  ; compare guess word to secret word
  If $msg = $GuessButton Then
   _GUICtrlMenu_EnableMenuItem($hWord, 6, 0)
   GUICtrlSetData($Guess, StringUpper(GUICtrlRead($Guess)))
   ;other stuff
   If TestWord(GUICtrlRead($Guess)) = True Then
    $Prep = True
    GUICtrlSetState($GuessButton, $GUI_HIDE)
    GUICtrlSetState($Guess, $GUI_DISABLE)
    DisplayWord($Number)
    If GUICtrlRead($Guess) = $TheWord Then
     Tada()
     MsgBox(262192, "Congratulations", "That is my word" & @CRLF & "You guessed it in " & $Number & " Guesses")
     UpdateStats($Number)
     DisplayStats()
     ExitLoop
    EndIf
    SaveWordFile()
    $Number += 1
   Else
    MsgBox(262160, "Mistake", GUICtrlRead($Guess) & " is not a valid word." & @CRLF & "Press OK to try another word")
    GUICtrlSetData($Guess, "")
    GUICtrlSetState($WordArray[$Number], $GUI_FOCUS)
   EndIf
  EndIf
  MenuCommands()
  ; ends the game prematurely and displays the secret word
  ; unless the game is at the beginning, then just exit game
  If $MenuActionFlag = $idGiveUp Then
   $MenuActionFlag = 0
   If $TheWord <> "" Then
    If MsgBox(262180, "Confirmation", "Are you sure you want to give up?") = 7 Then ContinueLoop
    MsgBox(262160, "You Lose.", "My word was " & $TheWord)
    If $Number > 1 Then
     UpdateStats(-1)
     DisplayStats()
    EndIf
   EndIf
   ExitLoop
  EndIf
  ; reset the alphabet to alpha state 0
  ; used if you discover your work is wrong
  If $MenuActionFlag = $idResetAlphabet Then
   $MenuActionFlag = 0
   If MsgBox(262180, "Confirmation", "Are you sure you want to reset the alphabet") = 7 Then ContinueLoop
   For $a = 1 To 26
    $AlphaState[$a] = 0
    ;$Alphabet[$a] = GUICtrlCreateButton(Chr(64 + $a), $a*$Square-$Square+5, 45, $Square, $Square)
    SetAlphaColor($a, $Alphabet[$a])
   Next
   For $Row = 1 To $Number - 1
    DisplayWord($Row)
   Next
   SaveWordFile()
   GUICtrlSetState($WordArray[$Number], $GUI_FOCUS)
  EndIf
  If $msg = $GUI_EVENT_CLOSE Or $MenuActionFlag = $idSaveExit Then
   _GUICtrlMenu_SetMenu($GameID, 0)
   GUIDelete($GameID)
   Exit
  EndIf
  If $MenuActionFlag = $idHelp Then
   $MenuActionFlag = 0
   ShellExecute("The Word Game.pdf")
  Endif
WEnd
FileDelete($GameFile)
_GUICtrlMenu_SetMenu($GameID, 0)
GUIDelete($GameID)
EndFunc   ;==>Game
;
; Determines whether system has detected a single or double click but not both
;
Func DetectClicks()
If $SingleClick Then
  $DoubleClickPause = TimerInit()
  Do
   Sleep(10)
   If $DoubleClick Then
    ActOnClick($DoubleClick, 2)
    $SingleClick = False
    ExitLoop
   EndIf
  Until TimerDiff($DoubleClickPause) > 100;$DoubleClickTime
  $DoubleClick = False
  If $SingleClick Then
   If Not $DoubleClick Then ActOnClick($SingleClick, 1)
  EndIf
  $SingleClick = False
EndIf
EndFunc
;
; Increase In or Out or Unknown state of alphabet letters
;  by one of two states depending on single or double clicks
;
Func ActOnClick($nID, $Clicks)
For $a = 1 To 26
  If $nID = $Alphabet[$a] Then
   $AlphaState[$a] += $Clicks
   If $AlphaState[$a] > 2 Then $AlphaState[$a] -= 3
   $ShowLetters = True
   Return $GUI_RUNDEFMSG
  EndIf
Next
For $a = 1 To 20
  For $b = 1 To 5
   If $nID = $LetterButtonArray[$a][$b] Then
    $Letter = Asc(GUICtrlRead($LetterButtonArray[$a][$b])) - 64
    $AlphaState[$Letter] += $Clicks
    If $AlphaState[$Letter] > 2 Then $AlphaState[$Letter] -= 3
    $ShowLetters = True
    Return $GUI_RUNDEFMSG
   EndIf
  Next
Next
EndFunc
; Determine Maximum Speed of clicks to still be a double click
;
Func _GetDoubleClickTime()
    Local $aResult = DllCall("user32.dll", "uint", "GetDoubleClickTime")
    If @error Then Return SetError(1,0,100)
    Return $aResult[0]
EndFunc
;
; detects clicks on letter buttons
; directs menu commands
;
Func _WM_COMMAND($hWnd, $msg, $wParam, $lParam)
Local $nNotifyCode = BitShift($wParam, 16)
Local $nID = BitAND($wParam, 0x0000FFFF)
; Local $hCtrl = $lParam
; alphebet single and double click detection
Switch ($nNotifyCode)
  Case $BN_DBLCLK
   $DoubleClick = $nID
  Case $BN_CLICKED
   $SingleClick = $nID
EndSwitch
; menu commands
Switch _WinAPI_LoWord($wParam)
  Case $idSetWord
   $MenuActionFlag = $idSetWord
  Case $idRandomWord
   $MenuActionFlag = $idRandomWord
  Case $idResetAlphabet
   $MenuActionFlag = $idResetAlphabet
  Case $idSaveExit
   $MenuActionFlag = $idSaveExit
  Case $idGiveUp
   $MenuActionFlag = $idGiveUp
  Case $idViewStats
   $MenuActionFlag = $idViewStats
  Case $idViewStatHistory
   $MenuActionFlag = $idViewStatHistory
  Case $idResetStats
   $MenuActionFlag = $idResetStats
  Case $idAbout
   $MenuActionFlag = $idAbout
  Case $idHelp
   $MenuActionFlag = $idHelp
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_COMMAND
;
; Respond to Menu Commands
;
Func MenuCommands()
Switch ($MenuActionFlag)
  Case $idViewStats
   DisplayStats()
  Case $idViewStatHistory
   DisplayStatHistory()
  Case $idResetStats
   If MsgBox(262180, "Confirmation", "Delete your previous statistics?") = 6 Then
    FileDelete($StatFile)
    MsgBox(262144, "Comment", "Previousd Statistics Deleted")
   EndIf
  Case $idAbout
   About()
  Case Else
   Return
EndSwitch
$MenuActionFlag = 0
EndFunc   ;==>MenuCommands
;
; Setup Main Menu Structure
;
Func SystemMenu($hGUI)
; Create File menu
$hWord = _GUICtrlMenu_CreateMenu()
_GUICtrlMenu_InsertMenuItem($hWord, 0, "Enter &Word", $idSetWord)
_GUICtrlMenu_InsertMenuItem($hWord, 1, "Set &Random Word", $idRandomWord)
_GUICtrlMenu_InsertMenuItem($hWord, 2, "", 0)
_GUICtrlMenu_InsertMenuItem($hWord, 3, "Reset &Alphabet", $idResetAlphabet)
_GUICtrlMenu_InsertMenuItem($hWord, 4, "", 0)
_GUICtrlMenu_InsertMenuItem($hWord, 5, "Save and E&xit", $idSaveExit)
_GUICtrlMenu_InsertMenuItem($hWord, 6, "&Give Up", $idGiveUp)
_GUICtrlMenu_EnableMenuItem($hWord, 3, 2)
_GUICtrlMenu_EnableMenuItem($hWord, 5, 2)
_GUICtrlMenu_EnableMenuItem($hWord, 6, 2)
_GUICtrlMenu_SetMenuStyle($hWord, $MNS_NOCHECK)
; Create Edit menu
$hStats = _GUICtrlMenu_CreateMenu()
_GUICtrlMenu_InsertMenuItem($hStats, 0, "&View Statistics", $idViewStats)
_GUICtrlMenu_InsertMenuItem($hStats, 1, "View Stat &History", $idViewStatHistory)
_GUICtrlMenu_InsertMenuItem($hStats, 2, "", 0)
_GUICtrlMenu_InsertMenuItem($hStats, 3, "Reset Statistics", $idResetStats)
_GUICtrlMenu_SetMenuStyle($hStats, $MNS_NOCHECK)
; Create Help menu
$hHelp = _GUICtrlMenu_CreateMenu()
_GUICtrlMenu_InsertMenuItem($hHelp, 0, "&Help", $idHelp)
_GUICtrlMenu_InsertMenuItem($hHelp, 1, "&About", $idAbout)
_GUICtrlMenu_SetMenuStyle($hHelp, $MNS_NOCHECK)
; Create Main menu
$hMain = _GUICtrlMenu_CreateMenu()
_GUICtrlMenu_InsertMenuItem($hMain, 0, "&Word", 0, $hWord)
_GUICtrlMenu_InsertMenuItem($hMain, 1, "&Stat", 0, $hStats)
_GUICtrlMenu_InsertMenuItem($hMain, 2, "&Help", 0, $hHelp)
; Set window menu
_GUICtrlMenu_SetMenu($hGUI, $hMain)
EndFunc   ;==>SystemMenu
;
; Credits
;
Func About()
Local $Display
$Display = $NameVersion & @CRLF & @CRLF
$Display &= "   - Written by Garth Bigelow" & @CRLF
$Display &= "   - with much patient help from the AutoIt help forums" & @CRLF & @CRLF
$Display &= "   - Copyright (c) 2012" & @CRLF
$Display &= "   - Program may be freely disseminated as long as no charge is levied." & @CRLF
MsgBox(262144, "About", $Display)
EndFunc   ;==>About
; SaveWordFile creates the game file which is used to continue a game if the game is closed while still in play
; $GameFile contains
;   The Secret Word
;   The Letter States (0,1 or 2) for Each Letter of the Alphabet
;   followed by each word guessed
; each entry on its own line
;
Func SaveWordFile()
$file = FileOpen($GameFile, 2) ; write fresh mode
; Check if file opened for reading OK
If $file = -1 Then
  MsgBox(0, @ScriptLineNumber, "Unable to open file.")
  Exit
EndIf
FileWriteLine($file, $TheWord)
For $Num = 1 To 26
  FileWriteLine($file, $AlphaState[$Num])
Next
For $Num = 1 To $Number
  If GUICtrlRead($WordArray[$Num]) >= "A" Then
   FileWriteLine($file, GUICtrlRead($WordArray[$Num]))
  EndIf
Next
FileClose($file)
EndFunc   ;==>SaveWordFile
;
; Tests whether $TestWord is in the dictionary
;   returns true if it is, false if it isn't
Func TestWord($TestWord)
$file = FileOpen($DictionaryFile, 0) ; read only mode
; Check if file opened for reading OK
If $file = -1 Then
  MsgBox(0, @ScriptLineNumber, "Unable to open file.")
  Exit
EndIf
; Read in lines of text until the EOF is reached
While True
  $word = FileReadLine($file)
  If @error = -1 Then ExitLoop
  $word = StringLeft($word, 5)
  If $word <> $TestWord Then ContinueLoop
  ; tidy up
  FileClose($file)
  ; valid word
  Return True
WEnd
; Tidy up
FileClose($file)
; Not a valid word
Return False
EndFunc   ;==>TestWord
;
; Returns the number of letters in the guess that are also in the secret word
;
Func GetCount($Char)
$Array1 = StringSplit($TheWord, "")
$Array2 = StringSplit(GUICtrlRead($WordArray[$Char]), "")
$Count = 0
For $a = 1 To 5
  For $b = 1 To 5
   If $Array1[$a] = $Array2[$b] Then $Count += 1
  Next
Next
Return $Count
EndFunc   ;==>GetCount
;
; Returns one random word from the dictionary
;
Func RandomWord()
$wordcount = 0
$file = FileOpen($DictionaryFile, 0) ; read only mode
; Check if file opened for reading OK
If $file = -1 Then
  MsgBox(0, @ScriptLineNumber, "Unable to open file.")
  Exit
EndIf
; count number of words
While True
  FileReadLine($file)
  If @error = -1 Then ExitLoop
  $wordcount += 1
WEnd
; record structure is a five letter word followed by a flag
;   if flag = 0 the word is common (and therefore eligible for being a secret word)
;          = 1 the word is rare
; keep picking random words until a common word is found
While True
  $ranword = FileReadLine($file, (Random(1, $wordcount - 1, 1)))
  If StringRight($ranword, 1) = 0 Then
   $ReturnWord = StringLeft($ranword, 5)
   ExitLoop
  EndIf
WEnd
FileClose($file)
; return the valid word
Return $ReturnWord
EndFunc   ;==>RandomWord
;
; Sets the secret word, either by manual entry or by random word from the dictionary
;
Func GetSecretWord()
$InitWord = ""
$file = ""
If FileExists($GameFile) Then
  $file = FileOpen($GameFile, 0) ; write read only
  ; Check if file opened for reading OK
  If $file = -1 Then
   MsgBox(0, @ScriptLineNumber, "Unable to open file.")
   Exit
  EndIf
  $TheWord = FileReadLine($file)
  FileClose($file)
  Return
EndIf
If Not FileExists($GameFile) Then
  While True
   $msg = GUIGetMsg()
   If $MenuActionFlag = $idSetWord Or $iniWordFlag = 1 Then
    $MenuActionFlag = 0
    $tempX = @DesktopWidth / 2 - 100
    $tempY = @DesktopHeight / 2 - 70
    $TheWord = InputBox("Select Word", "Enter The Game Word:", "", " M", -1, 140, $tempX, $tempY, 0, $GameID)
    If @error = 0 Then
     $TheWord = StringUpper($TheWord)
     If TestWord($TheWord) = True Then ExitLoop
     MsgBox(262160, "Word Problem", $TheWord & " is not a valid game word." & @CRLF & "Press OK to try another word")
    EndIf
   EndIf
   If $MenuActionFlag = $idRandomWord Or $iniWordFlag = 2 Then
    $MenuActionFlag = 0
    $TheWord = RandomWord()
    ExitLoop
   EndIf
   MenuCommands()
   If $msg = $GUI_EVENT_CLOSE Then Exit
  WEnd
EndIf
EndFunc   ;==>GetSecretWord
;
; Each letter of the alphabet has an associated state
;   0 - state is unknown
;   1 - letter is out
; 2 - letter is in
; This routine sets the states if a game is resumed
;
Func LoadAlphaStates()
If FileExists($GameFile) Then
  $file = FileOpen($GameFile, 0) ; write read only
  ; Check if file opened for reading OK
  If $file = -1 Then
   MsgBox(0, @ScriptLineNumber, "Unable to open file.")
   Exit
  EndIf
  For $Num = 1 To 26
   $AlphaState[$Num] = FileReadLine($file, $Num + 1)
  Next
  FileClose($file)
Else
  For $Num = 1 To 26
   $AlphaState[$Num] = 0
  Next
EndIf
EndFunc   ;==>LoadAlphaStates
;
; The states of the letters of the alphabet are displayed by a color
; This routine sets that color
;
Func SetAlphaColor($Char, $Object)
; debugging remove later
If $Char < 1 Or $Char > 26 Then Return
Switch $AlphaState[$Char]
  Case 0 ; Grey on Darker Gray
   GUICtrlSetBkColor($Object, 0xFFFFFF)
   GUICtrlSetColor($Object, 0x030203)
  Case 1 ; Disabled Mimic Colors
   GUICtrlSetBkColor($Object, $LetterOutBKColor)
   GUICtrlSetColor($Object, $LetterOutColor)
  ; GUICtrlSetBkColor($Object, 0xECF27E)
  ; GUICtrlSetColor($Object, 0x636162)
  Case 2 ; White on Red
   GUICtrlSetBkColor($Object, 0xFC0F03)
   GUICtrlSetColor($Object, 0xFFFFFF);  0xF4FC03)
EndSwitch
EndFunc   ;==>SetAlphaColor
;
; Display the word as a button for each letter and then
;   the number of letters between word and secret word
; Letters are displayed in their Alpha State colors
;
Func DisplayWord($Number)
; Remove Input Word Field
GUICtrlSetState($WordArray[$Number], $GUI_HIDE)
; Separate Word in Letters
$temp = GUICtrlRead($WordArray[$Number])
$Character = StringSplit($temp, "")
; Display Word
For $Num = 1 To 5
  GUICtrlSetData($LetterButtonArray[$Number][$Num], $Character[$Num])
  SetAlphaColor(Asc($Character[$Num]) - 64, $LetterButtonArray[$Number][$Num])
  GUICtrlSetState($LetterButtonArray[$Number][$Num], $GUI_SHOW)
Next
GUICtrlCreateLabel(" = " & GetCount($Number), 120, 23 + ($Number * 24), 90)
GUICtrlSetFont(-1, 17, 800)
; GUICtrlSetBkColor(-1, 0xE8E1E4)
GUICtrlSetColor(-1, 0x030203)
EndFunc   ;==>DisplayWord
;
; upon resuming the game the previous guesses are displayed
;
Func DisplayWords()
If Not FileExists($GameFile) Then Return 1
$file = FileOpen($GameFile, 0) ; read only
; Check if file opened for reading OK
If $file = -1 Then
  MsgBox(0, @ScriptLineNumber, "Unable to open file.")
  Exit
EndIf
$Count = 1
While True
  $word = FileReadLine($file, $Count + 27)
  If @error = -1 Then ExitLoop
  $WordArray[$Count] = GUICtrlCreateInput($word, 20, 25 + ($Count * 24), 80)
  DisplayWord($Count)
  $Count += 1
WEnd
FileClose($file)
Return $Count
EndFunc   ;==>DisplayWords
Func UpdateStats($guesses)
$file = FileOpen($StatFile, 1) ; write append
; Check if file opened for reading OK
If $file = -1 Then
  MsgBox(0, @ScriptLineNumber, "Unable to open file.")
  Exit
EndIf
FileWrite($file, $TheWord)
FileWrite($file, " ")
FileWriteLine($file, $guesses)
FileClose($file)
EndFunc   ;==>UpdateStats
Func DisplayStats()
Local $StatID, $file, $Wins, $Total, $Lost, $score, $msg
$file = FileOpen($StatFile, 0) ; read only
; Check if file opened for reading OK
If $file = -1 Then
  Return
EndIf
$Wins = 0
$Total = 0
$Lost = 0
While True
  $score = FileReadLine($file)
  If @error = -1 Then ExitLoop
  $score = StringRight($score, 2)
  If $score > 0 Then
   $Total += $score
   $Wins += 1
  Else
   If $score = -1 Then
    $Lost += 1
   EndIf
  EndIf
WEnd
$StatID = GUICreate("Statistics", 190, 110, -1, -1, BitOR($WS_CAPTION, $WS_SYSMENU, $WS_EX_TOPMOST), -1, $GameID)
GUISetFont(12, 800)
GUICtrlCreateLabel("Games Won:   " & $Wins, 10, 20)
If $Wins = 0 Then
  GUICtrlCreateLabel("Average Score: N/A", 10, 45)
Else
  GUICtrlCreateLabel("Average Score: " & Round($Total / ($Wins + $Lost), 2), 10, 45)
EndIf
GUICtrlCreateLabel("Games Lost:  " & $Lost, 10, 70)
GUISetState()
Do
  $msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE
GUIDelete($StatID)
EndFunc   ;==>DisplayStats
Func DisplayStatHistory()
Local $StatID, $StatEdit, $temp, $file, $line, $word, $score
$StatID = GUICreate("Statistics History", 230, 540, -1, -1, BitOR($WS_CAPTION, $WS_SYSMENU, $WS_EX_TOPMOST), -1, $GameID)
GUISetFont(14, 600, -1, "Courier New")
$temp = "  Word   Tries" & @CRLF & "  =====  ====="
$StatEdit = GUICtrlCreateEdit($temp, 10, 10, 210, 560)
GUISetState()
$file = FileOpen($StatFile, 0) ; read only
; Check if file opened for reading OK
If $file = -1 Then
  GUIDelete($StatID)
  Return
EndIf
; Determine Number of Words
; So that List can be lastest word first
$Count = 0
While True
  $line = FileReadLine($file)
  If @error = -1 Then ExitLoop
  $Count += 1
WEnd
; Exit if there are no words
If $Count = 0 Then
  GUIDelete($StatID)
  Return
EndIf
; Cycle thru the statistics file
While True
  $line = FileReadLine($file, $Count)
  $Count -= 1
  If $Count = 0 then ExitLoop
  ; ignore old style stat file entries
  If StringLen($line) < 5 Then ContinueLoop
  ; decode file line
  $word = StringLeft($line, 5)
  $score = StringRight($line, 2)
  ; display word
  $temp = GUICtrlRead($StatEdit)
  $temp &= @CRLF & "  " & $word & "  "
  ; display number of tries
  If $score = -1 Then
   $temp &= "Lost"
  Else
   ;   If $score < 10 Then $temp &= " "
   $temp &= "  " & $score
  EndIf
  GUICtrlSetData($StatEdit, $temp)
WEnd
Do
  $msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE
GUIDelete($StatID)
EndFunc   ;==>DisplayStatHistory
;
; Winning Hu-ra
;
Func Tada()
SoundPlay("TaDa.wav")
EndFunc   ;==>Tada
;
; Displays Error and Line of Error
;
Func ErrorBox($line, $content)
MsgBox(0, "Internal Error", $content & @CR & @CR & "Line: " & $line)
Exit
EndFunc   ;==>ErrorBox
Edited by Topher

[left][hr]
$mood = "whimsy"
$mode = "confused"
$randomChaos = True
Do
Something()
Until $Tired
[/left][left]Reflex (Arcade game)[/left][left]IX (Board game)[/left][left]The Word Game (Word game)[/left][left]Plastic Sliding Squares Puzzle (Puzzle)[/left]

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • seangriffin
      By seangriffin
      This is my first release of Box2D for AutoIT.  A very fun and exciting UDF to be bringing to you all.  For those who don't know, Box2D is a physics engine (see http://box2d.org/).  It simulates physical systems using rigid bodies and collision detection.  It is arguably the most prevalent physics engine in existence, within popular physics-based games like Angry Birds using it, and is also at the core of other advanced physics engines such as Unity.
      For a quick demonstration of this UDF in action see the following YouTube video ->  https://youtu.be/h5QH1O63Wik
      Or play "Angry Nerds", the demo game, for yourself.  Visit the EXAMPLES section below.
      Box2D is purely a mathematical engine.  It can model physics numerically.  This in itself is quite interesting, however it really shines when applied to a good graphics engine.  Recently I posted my SFML UDF over here ...
      After benchmarking several popular graphics engines (i.e. GDI+, Direct2D, Irrlicht and SFML) with this Box2D UDF I've selected SFML as my favourite, and the engine that I believe performs the best (fastest) with a rich set of functions appropriate for any physics engine.  With Box2D married with SFML, and running on AutoIT, the results are stunning.
      A HUGE THANK-YOU to jRowe and linus (for the Irrlicht UDF) and UEZ for his post on GDI+ loading screens and trancexx and Eukalyptus for their work on Direct2D.  Without their talents I would not have been able to reach this point on my own.
      The Box2D library is available for C++.  Way back in 2010 it was ported to Pure C by "Paril" and made available on Google Code and known as "Box2C".  Google Code has since been shut down but the but the archive of Box2C still exists to this day here -> https://code.google.com/archive/p/box2c.  This is the library which I have ported to AutoIT in this UDF.
      SFML I am also porting to AutoIT under a separate UDF, as linked above.
      Building this UDF has been a dream come true.  I've been fascinated by physics-based games as far back as the golden age of gaming in the 80's, with thrust style games like Asteroids and platformers like Donkey Kong.  I admired game developers like Jeremy Smith who created what may have been the first true game physics engines for the home computers.  I was astonished by their talents in games like Thrust and Exile for the C64.  Over the years I've attempted to mimic at least some of their success in my own games but alas I can not match their skills.  Now much older automation tools have become my game.  I use them almost every day, AutoIT included.  I've dabbled in other languages for physics game development, like Scratch and Unity, but sadly I had wondered why AutoIT, with all it's glorious capabilities and rapid scripting features, didn't have such a feature.  Hence this UDF.
      This UDF demands a big time investment, and I am time poor, but I have a keen interest in the topic and will do my best to continue it's development.  I am only a hobbyist game developer and welcome comments and suggestions from those far smarter than I on this topic.
      REQUIREMENTS:
      AutoIt3 3.2 or higher LIST OF FUNCTIONS (in progress):
      I've split this UDF into two halves.  "Box2C.au3" is a UDF specifically for Box2C, the C API for Box2D.  It provides the mathematics behind the engine.  Additionally I'm providing "Box2CEx.au3" as an Extension that provides the graphics and gaming functions for Box2D.
      Within the core "Box2C.au3" UDF:
      _Box2C_Startup _Box2C_Shutdown _Box2C_b2Vec2_Constructor _Box2C_b2Vec2_Length _Box2C_b2Vec2_Distance _Box2C_b2World_Constructor _Box2C_b2World_CreateBody _Box2C_b2World_DestroyBody _Box2C_b2World_CreateFixture _Box2C_b2World_CreateFixtureFromShape _Box2C_b2World_Step _Box2C_b2BoxShape_Constructor _Box2C_b2CircleShape_Constructor _Box2C_b2PolygonShape_Constructor _Box2C_b2PolygonShape_Set _Box2C_b2PolygonShape_CrossProductVectorScalar _Box2C_b2PolygonShape_CrossProductVectorVector _Box2C_b2PolygonShape_Normalize _Box2C_b2PolygonShape_ComputeCentroid _Box2C_b2BodyDef_Constructor _Box2C_b2Body_DestroyFixture _Box2C_b2Body_GetPosition _Box2C_b2Body_SetPosition _Box2C_b2Body_GetAngle _Box2C_b2Body_SetAngle _Box2C_b2Body_SetAwake _Box2C_b2Body_SetTransform _Box2C_b2Body_GetLinearVelocity _Box2C_b2Body_SetLinearVelocity _Box2C_b2Body_GetAngularVelocity _Box2C_b2Body_SetAngularVelocity _Box2C_b2Body_ApplyForce _Box2C_b2Body_ApplyForceAtBody _Box2C_b2Body_ApplyDirectionalForceAtBody _Box2C_b2Body_ApplyTorque _Box2C_b2Fixture_GetShape _Box2C_b2Fixture_GetDensity _Box2C_b2Fixture_SetDensity _Box2C_b2Fixture_GetRestitution _Box2C_b2Fixture_SetRestitution _Box2C_b2Fixture_GetFriction _Box2C_b2Fixture_SetFriction _Box2C_b2Fixture_SetSensor Within y "Box2CEx.au3" extension:
      x_metres_to_gui_x y_metres_to_gui_y metres_to_pixels atan2 radians_to_degrees degrees_to_radians _Box2C_Setup_SFML _Box2C_b2Vec2_GetGUIPosition _Box2C_b2World_Setup _Box2C_b2World_GDIPlusSetup _Box2C_b2World_SetPixelsPerMetre _Box2C_b2World_SetGUIArea _Box2C_b2World_GetGUIArea _Box2C_b2World_GetGUIAreaCenter _Box2C_b2World_Create _Box2C_b2World_Step_Ex _Box2C_b2World_StartAnimation _Box2C_b2World_Animate_SFML _Box2C_b2World_Animate_GDIPlus _Box2C_b2World_WaitForAnimateEnd _Box2C_b2ShapeArray_AddItem_SFML _Box2C_b2ShapeArray_SetItem_SFML _Box2C_b2ShapeArray_GetItemImagePath_SFML _Box2C_b2PolygonShape_ArrayAdd_Irrlicht _Box2C_b2PolygonShape_ArrayAdd_GDIPlus _Box2C_b2BodyDefArray_AddItem _Box2C_b2FixtureArray_SetItemSensor _Box2C_b2FixtureArray_GetItemDensity _Box2C_b2FixtureArray_SetItemDensity _Box2C_b2FixtureArray_GetItemRestitution _Box2C_b2FixtureArray_SetItemRestitution _Box2C_b2FixtureArray_GetItemFriction _Box2C_b2FixtureArray_SetItemFriction _Box2C_b2BodyArray_AddItem_SFML _Box2C_b2Body_ArrayAdd_Irrlicht _Box2C_b2Body_ArrayAdd_GDIPlus _Box2C_b2BodyArray_GetItemCount _Box2C_b2BodyArray_GetItemPosition _Box2C_b2BodyArray_SetItemPosition _Box2C_b2BodyArray_GetItemAngle _Box2C_b2BodyArray_SetItemAngle _Box2C_b2BodyArray_GetItemLinearVelocity _Box2C_b2BodyArray_SetItemActive _Box2C_b2BodyArray_SetItemAwake _Box2C_b2BodyArray_SetItemImage_SFML _Box2C_b2BodyArray_SetItemDraw _Box2C_b2BodyArray_ApplyItemForceAtBody _Box2C_b2BodyArray_ApplyItemDirectionalForceAtBody _Box2C_b2BodyArray_Transform_SFML _Box2C_b2Body_Transform_GDIPlus _Box2C_b2BodyArray_Draw_SFML _Box2C_b2Body_ArrayDrawDisplay_SFML _Box2C_b2Body_Destroy _Box2C_b2Body_Destroy_SFML _Box2C_b2Body_Rotate_GDIPlus The SFML functions used in the tests and demos will be available in the SFML UDF post (see reference above).
      EXAMPLES:
      For such a powerful physics engine coupled to such a powerful graphics engine (SFML) it's sad that I've only had time to build one functional game, thus far.  But it's a start.
      My self-titled "Angry Nerds" is merely a demo of the same game concept as the ever-so-popular Angry Birds game.  Angry Birds itself is built on top of Box2D.  Likewise Angry Nerds.  AutoIT + Box2D + SFML to be exact.  I've compiled Angry Nerds and provided an installer also, so you can quickly run the demo for yourself.  From the Github site below (in the DOWNLOAD section) run "Box2C_Angry_Nerds_Game_SFML_installer.exe" to install the demo to a location on your computer (desktop by default).  Go into this folder and run "Box2C_Angry_Nerds_Game_SFML.exe".  All instructions are displayed in-game.  Should be quite easy to work out.
      Aside from Angry Nerds there are also two test scripts:
      Box2C_linear_forces_test_SFML.au3 Box2C_angular_forces_test_SFML.au3 Feel free to run these for a basic demonstration of rigid bodies, forces and collisions.  The heart of Box2D and any physics engine.
      Lastly I also have four speed tests as follows:
      Box2C_speed_test_SFML.au3 Box2C_speed_test_Irrlicht.au3 Box2C_speed_test_D2D.au3 Box2C_speed_test_GDIPlus.au3 These were my initial evaluations into a suitable graphics engine for Box2D.  I've since settled on SFML, but feel free to execute these.  Note they may become quick defective over time as the SFML functions slowly take over.
      DOWNLOADS:
      You can download this UDF, including the examples above and associated files, from the following GitHub page:
      https://github.com/seanhaydongriffin/Box2C-UDF
      Hope you all enjoy!  I certainly am :-)
      Cheers,
      Sean.
       
    • Triblade
      By Triblade
      Hi folks!
       
      First off, yeah this may be the lamest title. But it made you look anyway! 
       
      Edit: Now updated! With step-counter, reset button and a few GUI-tweaks. (the step-counter is cheating! It's calculated in advance...)
      I recently thought a screenshot of a finished maze may be smart to show, instead of only my long story and code. o=path, x=wall. Here it is:
       

       
      I started making my own implementation of the A* pathing script in a larger project, inspired by Toady's work. (But made one from scratch myself anyway )
      After the A* pathing script was working (not cleaned up yet) I wanted to test it. Unfortunately I got no good, randomized, maze lying around that also had the format I needed. So I made my own maze generator!
       
      I did a few hours of research on the matter and then a few evenings of scripting.
      For the people who are interested, one of my problems was that I needed 'one-cell' thick walls. Most maze generation have 1 pixel thick walls drawn by a line, that could be opened if a path is needed. The solution is so simple, I needed this guy to tell me. Click here for my inspiration source.
       
      This generator can be used with different sizes maze, even uneven ones! Just set the width and height settings. FYI, it must be odd numbers for this maze to work with it's containment walls.
      It's the 'simple' Depth-First Search, with backtracking. And without further ado; my a-maze-ing generator!:
      #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.12.0 Author: A-maze-ing generator Script Function: Generates a maze. In the $xy[$i][4] is the maze in array form. Don't forget to take the size with it, else it's just a string of o's and x's It does not generate an entrance or exit! #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <Array.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> ; Set various variables ; width and height must be odd numbers to have a closed, functioning maze. Global $height = 27 ; demo height = 27 Global $width = 43; demo width = 43 ; Check if width & height are an odd number (to get the outer edge an odd number is required) If mod($height, 2) = 0 Or $height < 5 Then msgbox(0,"","Height is not an odd number or a minimum of 5 tall !") Exit ElseIf mod($width, 2) = 0 Or $width < 5 Then msgbox(0,"","Width is not an odd number of a minimum of 5 wide !") Exit EndIf ; Set various variables when script is not exited Global $grid_size = $height * $width Global $numberofsteps = (Ceiling(($height-2) / 2) * (($width-2) - Ceiling(($width-2) / 2))) + (($height-2) - Ceiling(($height-2) / 2)) ; long formula to check the number of steps this maze will take, this is a mathematical given with a fixed number of cells. And yes, I am aware I'm taking a shortcut in this formula. ;) Global $curpos Global $backtrack[1] Global $bt = 0 Local $grid_pixel = 20 ;How many pixels per square ; Initialize main array with all grid data Global $xy[$grid_size + 1][5] Global $reset_xy = $xy ; set the reset array $xy[0][0] = $grid_size ; first entry is the total number of nodes, rest is set with a header name for easy reference in _ArrayDisplay if needed. $xy[0][1] = "ID" $xy[0][2] = "Row" $xy[0][3] = "Column" $xy[0][4] = "Type" ; Fill the grid array with 'walls' For $i = 1 To $xy[0][0] $xy[$i][4] = "x" Next ; Start GUI and create standard buttons Local $gui = GUICreate("A-maze-ing generator", 180 + ($width * $grid_pixel), 80 + ($height * $grid_pixel)) ; Set the main window to the minimum width (IF) needed for the msgbox Local $aPos = WinGetPos($gui) If $aPos[2] < 696 Then $aPos[2] = 696 WinMove($gui, "", $aPos[0], $aPos[1], $aPos[2], $aPos[3]) EndIf GUICtrlCreateLabel("This is a-maze-ing!", 30, 19) Global $progress = GUICtrlCreateLabel("Standing by... " & $numberofsteps & " steps to go.", 150, 15, 550, 30) Local $iOKButton = GUICtrlCreateButton("Start", 45, 50, 60) Local $iResetButton = GUICtrlCreateButton("Reset", 45, 90, 60) Local $iExitButton = GUICtrlCreateButton("Exit", 45, 130, 60) GUICtrlSetFont($progress, 15) GUICtrlSetColor($progress, 0x00AA00) GUICtrlSetState($iResetButton, $GUI_DISABLE) ; Create label-grid and fill the xy array with the positions Local $squarenr = 0 For $i = 0 To ($height * $grid_pixel) - $grid_pixel Step $grid_pixel ; Row For $j = 0 To ($width * $grid_pixel) - $grid_pixel Step $grid_pixel ; Column $squarenr = $squarenr + 1 $xy[$squarenr][0] = GUICtrlCreateLabel('x', 150 + $j, 50 + $i, $grid_pixel, $grid_pixel, BitOr($SS_SUNKEN, $SS_CENTER)) ; if you want debugging numbers, replace 'x' with $squarenr GUICtrlSetBkColor($xy[$squarenr][0], 0x5E87C9) ; lightblue-ish $xy[$squarenr][1] = $squarenr $xy[$squarenr][2] = ($i / $grid_pixel) + 1 $xy[$squarenr][3] = ($j / $grid_pixel) + 1 Next Next $reset_xy = $xy ; Show GUI GUISwitch($gui) GUISetState(@SW_SHOW) ; Start looping and waiting for input Local $aMsg = 0 While 1 $aMsg = GUIGetMsg(1) Select Case $aMsg[0] = $iOKButton GUICtrlSetState($iOKButton, $GUI_DISABLE) GUICtrlSetState($iResetButton, $GUI_DISABLE) GUICtrlSetState($iExitButton, $GUI_DISABLE) GUICtrlSetColor($progress, 0xFF8C00) ; orange GUICtrlSetData($progress, "Running - Creating maze. Please stand by... " & $numberofsteps & " steps to go.") make_maze() GUICtrlSetColor($progress, 0xFF0000) ; red GUICtrlSetData($progress, "Maze complete!") Sleep(1000) ; Just a small sleep for dramatic effect GUICtrlSetColor($progress, 0x00AA00) ; green-ish GUICtrlSetData($progress, "Maze completed in " & $numberofsteps & " steps.") GUICtrlSetState($iResetButton, $GUI_ENABLE) GUICtrlSetState($iExitButton, $GUI_ENABLE) Case $aMsg[0] = $iResetButton GUICtrlSetData($progress, "Resetting maze...") reset_maze() GUICtrlSetState($iResetButton, $GUI_DISABLE) GUICtrlSetState($iOKButton, $GUI_ENABLE) GUICtrlSetData($progress, "Maze reset!") Sleep(1000) ; Just a small sleep for dramatic effect GUICtrlSetData($progress, "Standing by...") Case $aMsg[0] = $GUI_EVENT_CLOSE Or $aMsg[0] = $iExitButton ExitLoop EndSelect WEnd Exit ; Resetting the maze to default state Func reset_maze() $xy = $reset_xy ; Set the $xy array back to it first-run values For $i = 1 To $xy[0][0] $xy[$i][4] = "x" ; set everything to 'x' GUICtrlSetBkColor($xy[$i][0], 0x5E87C9) ; reset the background color GUICtrlSetData($xy[$i][0], "x") ; (re)set the label to 'x' Next EndFunc ; Main function Func make_maze() Local $heading Local $stepcount = $numberofsteps ; Reset the step counter. Local $timed = TimerInit() ; Start the timer to see how long the maze generation took. $backtrack[0] = 0 $curpos = $width + 2 ; This is the starting position, second row, second column - aka top-left, one in from the sides. open_maze($curpos) ; Set the starter cell to 'open / white' ; Main maze generation loop While 1 Do $heading = direction($curpos) Until $heading <> 0 If $bt = 1 Then $bt = 0 ; reset backtracking-tracker, else the backtracking array keeps adding the current position GUICtrlSetData($progress, "Running - Creating maze. Please stand by... " & $stepcount & " steps to go.") Sleep(50) ; Slow maze creation down to look at it - relax! (or don't and comment out the sleep) If $heading = -1 Then ExitLoop $stepcount -= 1 ; Count down the steps to finish. ; We got the heading - now which way do we go? After that, set the current position to the last known heading. Switch $heading Case 1 ; north open_maze($curpos - $width) open_maze($curpos - ($width * 2)) $curpos = $curpos - ($width * 2) Case 2 ; east open_maze($curpos + 1) open_maze($curpos + 2) $curpos = $curpos + 2 Case 3 ; south open_maze($curpos + $width) open_maze($curpos + ($width * 2)) $curpos = $curpos + ($width * 2) Case 4 ; west open_maze($curpos - 1) open_maze($curpos - 2) $curpos = $curpos - 2 EndSwitch ;msgbox(0,"","Turn pause") ; for debugging, click every turn. WEnd ConsoleWrite("Maze completed in " & Round(TimerDiff($timed) / 1000, 1) & " seconds." & @CRLF) ; Show the generation time in seconds, rounded up with one decimal Return EndFunc Func open_maze($dest) ; Function set inputted cells to 'open' instead of being an uncool wall. $xy[$dest][4] = "o" GUICtrlSetData($xy[$dest][0], 'o') ; If you want debugging numbers, replace 'o' with $dest GUICtrlSetBkColor($xy[$dest][0], 0xEEEEEE) EndFunc Func direction(ByRef $curpos) ; Insert current position, output next heading for path generation. Local $nesw Local $open_directions[5][2] $open_directions[0][0] = 0 $nesw = $curpos - ($width * 2) ; north side checking If $nesw > $width + 1 Then fill_open_dir($nesw, 1, $open_directions) $nesw = $curpos + 2 ; east side checking If mod($nesw - 1, $width) <> 0 Then fill_open_dir($nesw, 2, $open_directions) $nesw = $curpos + ($width * 2) ; south side checking If $nesw < $grid_size - $width Then fill_open_dir($nesw, 3, $open_directions) $nesw = $curpos - 2 ; west side checking If mod($nesw, $width) <> 0 Then fill_open_dir($nesw, 4, $open_directions) ; Check which (if any) direction(s) are already opened, if so, discard them from the results-array For $i = $open_directions[0][0] To 1 Step -1 If $xy[$open_directions[$i][1]][4] = "o" Then $open_directions[0][0] -= 1 _ArrayDelete($open_directions, $i) EndIf Next ; If there are any results left... If $open_directions[0][0] > 0 Then If $open_directions[0][0] = 1 Then Return $open_directions[1][0] ; Random does not work with min 1 and max 1 (output = 0), so in this case, return only with the only one result. Else If $bt = 0 Then ; If there is not backtracking active, add this crossroad to the backtrack-array. This is only needed if there are two or three possible sides. $backtrack[0] += 1 _ArrayAdd($backtrack, $curpos) EndIf Return $open_directions[Random(1, $open_directions[0][0], 1)][0] ; Random choose between all possible directions and return with the outcome direction. EndIf ElseIf $backtrack[0] > 0 Then ; If there are no results ánd there are entries in the backtrack list, then visit those entries to see if there still is a path possible. $curpos = $backtrack[$backtrack[0]] _ArrayDelete($backtrack, $backtrack[0]) $backtrack[0] -= 1 $bt = 1 Return 0 ; Return with a new current direction ($curpos), from the backtrack array. Else Return -1 ; If there are no paths to explorer, in the pathing, or backtracking, then return with the message that we are finished. EndIf EndFunc Func fill_open_dir($nesw, $direction, ByRef $open_directions) ; Fill the $open_directions array with a new possible way $open_directions[0][0] += 1 $open_directions[$open_directions[0][0]][1] = $nesw $open_directions[$open_directions[0][0]][0] = $direction Return EndFunc  
      P.S.  The 'slow' generation is intended because it looks cool. Comment out the Sleep line on line 157 for a fast generation.
    • rm4453
      By rm4453
      Hey guys! I need to find a way to wrap an autoit gui around a game. I am planning on making a custom gui overlay for interacting with my stream, which will allow me to run giveaways and stuff like that. But I need to find a way to force the steam games to run inside my autoit gui... I have the following code so far credit to those I took code from and modified to suite my needs "can't remember who u are pls post if i owe ty to u" If I select notepad and launch it then it works great! and the notepad window is wrapped inside my gui. However if I try it with teamfortress 2 it won't work...
       
      #include <Array.au3> #include <File.au3> #include <WinAPI.au3> #include <GUIConstants.au3> Local $msg, $hwnd, $WinHwnd ;===> UDV Start $pid = 0 $Hidden = 0 $exe = 0 $sDrive = 0 $sDir = 0 $sFileName = 0 $sExtension = 0 ;===> UDV End $hwnd = GUICreate("hello") $Open = GUICtrlCreateButton("Launch Game", 10, 30, 75, 25) $Select = GUICtrlCreateButton("Select Game", 10,60,75,25) GUISetState() ;===> UDF START Func _GetWinHwnd($pid) $aWinlist = WinList() For $i = 1 To $aWinlist[0][0] If $pid = WinGetProcess($aWinlist[$i][0]) Then Return $aWinlist[$i][0] Next EndFunc ;==>_GetWinHwnd Func _SetParentWindow($pid) $WinInfo = _GetWinHwnd($pid) $WinHwnd = ControlGetHandle($WinInfo, "", "") _WinAPI_SetParent($WinHwnd, $hwnd) _WinAPI_SetWindowLong($WinHwnd, $GWL_STYLE, $WS_POPUP + $WS_VISIBLE) WinMove($WinHwnd, "", 0, 0) EndFunc ;==>_SetParentWindow Func RedrawGui($RedrawMe) If ProcessExists($pid) And $Hidden = 0 Then GUICtrlSetState($RedrawMe, @SW_HIDE) $Hidden = 1 sleep(50) _WinAPI_RedrawWindow($pid) Sleep(50) ElseIf $Hidden = 1 And Not ProcessExists($pid) Then GUICtrlSetState($RedrawMe, @SW_SHOW) $Hidden = 0 EndIf EndFunc ;===> UDF END While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE If ProcessExists($pid) Then ProcessClose($pid) GUICtrlSetState($Open, @SW_SHOW) Else Exit EndIf Case $Open GUICtrlSetState($Open, @SW_HIDE) Sleep(100) $pid = Run('"' & $exe & '" -game tf -steam') #cs This RUN CMD is custom made for testing with TF2 change to just $exe to select any exe you want to test with -game tf specifies to launch tf2 and -steam gets rid of insecure mode error #ce RedrawGui($Open) ProcessWait($pid) Sleep(5500) _GetWinHwnd($pid) _SetParentWindow($pid) Case $Select $exe = FileOpenDialog("Please select your game!", @ScriptDir, "Executable File (*.exe)", "1", "Process Selection") Sleep(50) FileChangeDir(@ScriptDir) _PathSplit($exe, $sDrive, $sDir, $sFileName, $sExtension) EndSwitch WEnd  
    • Wingens
      By Wingens
      Hi,
      I don't know if it is possible but I am creating a little program to catalog my game collection.
      It would be awesome if my program could get the boxcover, developer info and game info with the titles I add.
      Does anyone know how to get me started?
    • UEZ
      By UEZ
      Here my 1st game ever.
       
      A try to remake of the arcade classical 2D game Asteroids® by Atari (1979).
       
      More information about Asteroids® here or here!
       
      Play online here
       
       
      Please don't link to file below directly from other websites!
       
      Downloads (2263 previously):  AUTOITEROIDS v1.019 Build 2016-01-14.7z (use e.g. 7-Zip to extract archive)
       
      Only compiled version incl. needed files here: <4shared.com> or <MediaFire.com>
       
       

       
       
       
      LEGAL NOTICE:
       
      This game is an unoffical clone of the original Asteroids®
      game and is not endorsed by the registered trademark
      and copyright owners Atari Interactive, Inc.
       
       
       
      Short description:
       
      AUTOITEROIDS is a remake of the video arcade game released in 1979 by Atari, Inc.
      It was one of the most popular and influential games of the Golden Age of Arcade Games.
      The player controls a spaceship in an asteroid field which is periodically traversed by flying saucers.
      The object of the game is to shoot and destroy asteroids and saucers while not colliding with either,
      or being hit by the saucers' counter-fire.
       
       
      Keys:
       
      ctrl - shoot,
      up - thrust,
      left - turn left,
      right - turn right,
      space - hyper jump
       
       
      Game details:
       
      game is starting with 3 asteroids
      every 10.000 points increase of level (among other things amount of asteroids + 1)
      every 30.000 points extra live
      biggest asteroid = 20 points
      medium asteroid = 50 points
      smallest asteroid = 100 points
      big alien spaceship = 200 points
      small alien spaceship = 1000 point
       
       
      Credits:
       
      Main code: UEZ
      Bass UDF: BrettF
      Bass DLL: www.un4seen.com
      GDI+ font loader code: Yashied
      Menu item code: rasim
      Sound + sound code modifications: Spiff59
      Font: ck! [Freaky Fonts]
      GetKeyboardState code: eukalyptus
      Atari for the original game concept
      AutoIt forum for all the help and the source of knowledge
       
      Have fun
      UEZ

       
       
      Change log: