Jump to content

Frog Maze - Game


FaridAgl
 Share

Recommended Posts

I hope you like it.

Posted Image

#NoTrayIcon
#AutoIt3Wrapper_Icon=Resources\Icon.ico
#AutoIt3Wrapper_Outfile=Frog Maze.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Res_Comment=This software is freeware and may be used and/or distributed freely under the assumption the contents of the archive are not changed or altered in any way and it's contents are intact.
#AutoIt3Wrapper_Res_Description=Developer : D4RK.ON3 | aghili_farid@yahoo.com
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=© 2010-2011 D4RK.ON3. All Rights Reserved.
#AutoIt3Wrapper_Run_AU3Check=n
#AutoIt3Wrapper_Tidy_Stop_OnError=n
#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/SF=1 /SV=1 /CV=1 /CF=1 /CS=1 /CN=1 /OM
#include <Misc.au3>
Opt("GUICloseOnESC", 0)
Opt("PixelCoordMode", 2)
FileInstall("Resources\Fly.jpg", @TempDir & "\Fly.jpg", 1)
FileInstall("Resources\Maze.bmp", @TempDir & "\Maze.bmp", 1)
FileInstall("Resources\Frog.jpg", @TempDir & "\Frog.jpg", 1)
Const $Title = "Frog Maze"
_Singleton($Title)
Global $BestScore = 99999, $First = 1
$GUI = GUICreate($Title, 640, 480)
GUISetBkColor(0xFFFFFF)
GUICtrlCreateGroup("Coordinate", 530, 400, 100, 70)
GUICtrlCreateLabel("X Pos:", 540, 420, 35, 17)
GUICtrlCreateLabel("Y Pos:", 540, 445, 35, 17)
$X = GUICtrlCreateLabel(122, 580, 420, 35, 17)
$Y = GUICtrlCreateLabel(37, 580, 445, 35, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("Game Field", 10, 10, 620, 380)
GUICtrlCreatePic(@TempDir & "\Maze.bmp", 113, 35, 443, 331)
$Fly = GUICtrlCreatePic(@TempDir & "\Fly.jpg", 538, 366, 19, 20)
$Frog = GUICtrlCreatePic(@TempDir & "\Frog.jpg", 122, 37, 5, 5)
GUICtrlSetBkColor($Frog, 0xFF0000)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("Help", 10, 400, 315, 70)
GUICtrlCreateLabel("Use the Arrow keys to reach the Fly through the Maze.", 20, 420, 276, 17)
GUICtrlCreateLabel("Press Enter to restart the Game.", 20, 445, 154, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("State", 335, 400, 185, 70)
GUICtrlCreateLabel("Time Spent:", 345, 420, 61, 17)
$Timer = GUICtrlCreateLabel(0, 410, 420, 16, 17, 0x1)
GUICtrlCreateLabel("second(s).", 435, 420, 53, 17)
GUICtrlCreateLabel("Best Score:", 345, 445, 59, 17)
$Score = GUICtrlCreateLabel("?", 410, 445, 16, 17, 0x1)
GUICtrlCreateLabel("second(s).", 435, 445, 53, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState()
;~ ----------------------------------------------------------------------------------------------------
While 1
Switch GUIGetMsg()
  Case -3
   Exit
EndSwitch
Select
  Case _IsPressed(25)
   If $First = 1 Then
    _FirstMove()
   Else
    _Move("Left")
   EndIf
  Case _IsPressed(26)
   If $First = 1 Then
    _FirstMove()
   Else
    _Move("Up")
   EndIf
  Case _IsPressed(27)
   If $First = 1 Then
    _FirstMove()
   Else
    _Move("Right")
   EndIf
  Case _IsPressed(28)
   If $First = 1 Then
    _FirstMove()
   Else
    _Move("Down")
   EndIf
  Case _IsPressed("0D")
   If WinActive($Title, "Game Field") Then _Restart()
EndSelect
WEnd
;~ ----------------------------------------------------------------------------------------------------
Func _Move($Key)
If WinActive($Title, "Game Field") Then
  Switch $Key
   Case "Left"
    If _Left() Then
     GUICtrlSetPos($Frog, GUICtrlRead($X) - 2, GUICtrlRead($Y))
     GUICtrlSetData($X, GUICtrlRead($X) - 2)
    EndIf
   Case "Up"
    If _Up() Then
     GUICtrlSetPos($Frog, GUICtrlRead($X), GUICtrlRead($Y) - 2)
     GUICtrlSetData($Y, GUICtrlRead($Y) - 2)
    EndIf
   Case "Right"
    If _Right() Then
     GUICtrlSetPos($Frog, GUICtrlRead($X) + 2, GUICtrlRead($Y))
     GUICtrlSetData($X, GUICtrlRead($X) + 2)
    EndIf
   Case "Down"
    If _Down() Then
     GUICtrlSetPos($Frog, GUICtrlRead($X), GUICtrlRead($Y) + 2)
     GUICtrlSetData($Y, GUICtrlRead($Y) + 2)
    EndIf
  EndSwitch
  _Check()
EndIf
EndFunc   ;==>_Move
Func _FirstMove()
$First = 0
AdlibRegister("_Timer", 1000)
EndFunc   ;==>_FirstMove
Func _Left()
$FrogPos = ControlGetPos($Title, "Game Field", "[CLASS:Static; INSTANCE:7]")
If Hex(PixelGetColor($FrogPos[0] - 1, $FrogPos[1] + 2, $GUI), 6) = 010080 Then
  Return 0
Else
  Return 1
EndIf
EndFunc   ;==>_Left
Func _Up()
$FrogPos = ControlGetPos($Title, "Game Field", "[CLASS:Static; INSTANCE:7]")
If Hex(PixelGetColor($FrogPos[0] + 2, $FrogPos[1] - 1, $GUI), 6) = 010080 Then
  Return 0
Else
  Return 1
EndIf
EndFunc   ;==>_Up
Func _Right()
$FrogPos = ControlGetPos($Title, "Game Field", "[CLASS:Static; INSTANCE:7]")
If Hex(PixelGetColor($FrogPos[0] + 5, $FrogPos[1] + 2, $GUI), 6) = 010080 Then
  Return 0
Else
  Return 1
EndIf
EndFunc   ;==>_Right
Func _Down()
$FrogPos = ControlGetPos($Title, "Game Field", "[CLASS:Static; INSTANCE:7]")
If Hex(PixelGetColor($FrogPos[0] + 2, $FrogPos[1] + 5, $GUI), 6) = 010080 Then
  Return 0
Else
  Return 1
EndIf
EndFunc   ;==>_Down
Func _Check()
$FrogPos = ControlGetPos($Title, "Game Field", "[CLASS:Static; INSTANCE:7]")
If Number($FrogPos[0]) >= 542 And Number($FrogPos[0]) <= 547 Then
  If Number($FrogPos[1]) >= 366 And Number($FrogPos[1]) <= 370 Then
   If Number(GUICtrlRead($Timer)) < Number($BestScore) Then
    $BestScore = GUICtrlRead($Timer)
    GUICtrlSetData($Score, GUICtrlRead($Timer))
   EndIf
   MsgBox(64, $Title, "Congratulations! You have won the Fly!" & @CRLF & "Your best score is " & $BestScore & " Second(s)" & @CRLF & "Click OK to restart the Game.", 0, $GUI)
   _Restart()
  EndIf
EndIf
EndFunc   ;==>_Check
Func _Timer()
GUICtrlSetData($Timer, GUICtrlRead($Timer) + 1)
EndFunc   ;==>_Timer
Func _Restart()
$First = 1
AdlibUnRegister("_Timer")
GUICtrlSetData($X, 122)
GUICtrlSetData($Y, 37)
GUICtrlSetPos($Frog, 122, 37)
GUICtrlSetData($Timer, 0)
EndFunc   ;==>_Restart

Zip Package:

http://www.mediafire.com/?df9t0fb9s6peq63

Compiled:

http://www.mediafire.com/?j38q9qqzwluc6c6

Link to comment
Share on other sites

Perfect! Very good indeed, thanks for sharing.

Best regards,

Edit: But the beetle is not flying... What could be, I use Windows 7 32bit.

Wow, now I understand how it works! I'm sorry.

João Carlos.

Edited by jscript

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Link to comment
Share on other sites

That should not fly, you start the game from on side and should reach to other side to exit the Maze.

The beetle goes nowhere, it is still!

Wow, now I understand how it works! I'm sorry.

João Carlos.

Edited by jscript

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Link to comment
Share on other sites

112 seconds for the difficult one


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...