Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/11/2015 in all areas

  1. AutoIt Version: 3.3.10.2+ UDF Version: 2.0 Description: This library allows to register function for AutoIt critical errors. Usually it's syntax errors, or array-related errors. By default the UDF shows custom debug dialog, although it is not possible to perform any real debugging, but we can for example display the error message, restart application, send bug report, or just close the application. Example #1 - Displaying built-in dialog when error is received: #NoTrayIcon #AutoIt3Wrapper_Run_Before=%autoitdir%\AutoIt3.exe /AutoIt3ExecuteLine "FileClose(FileOpen('%scriptdir%\OAER_RAW_SRC.tmp', 2))" #AutoIt3Wrapper_Run_After=%autoitdir%\AutoIt3.exe /AutoIt3ExecuteLine "FileDelete('%scriptdir%\OAER_RAW_SRC.tmp')" #include <GUIConstantsEx.au3> #include 'OnAutoItErrorRegister.au3' _OnAutoItErrorRegister('', '', 'My App Error', False, False) GUICreate('OnAutoItErrorRegister Example', 350, 200) GUICtrlCreateLabel('This script is just an example.' & @CRLF & @CRLF & 'It will produce a syntax error in', 25, 40, 300, 50) GUICtrlCreateLabel('5', 185, 50, 50, 40) GUICtrlSetColor(-1, 0xF20000) GUICtrlSetFont(-1, 30, 800, 0, 'Tahoma') GUICtrlCreateLabel('seconds.', 220, 67, 300, 50) GUICtrlCreateLabel('The result shown as a CUSTOM error message, you can change it!', 25, 120, 350, 20) $iUnRegister_Bttn = GUICtrlCreateButton('UnRegister AutoItError handler', 25, 140, 200, 22) GUICtrlCreateLabel('Copyright jennico, G.Sandler (MrCreatoR) © 2008 - 2015', 25, 170, 350, 80) GUICtrlSetColor(-1, 0x808080) GUICtrlSetFont(-1, 8.5, 800, 6) GUISetState() Dim $iTimer For $i = 3 To 1 Step -1 GUICtrlSetData(4, $i) $iTimer = TimerInit() While TimerDiff($iTimer) < 1000 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $iUnRegister_Bttn _OnAutoItErrorUnRegister() EndSwitch WEnd Next ;We deliberately make a syntax mistake and call the error! If Random(1, 5, 1) = 3 Then MsgBox(0, '', ) Else _NotExistingFunc() EndIf Example #2 - Call user defined function when receiving error (script restart): #NoTrayIcon #AutoIt3Wrapper_Run_AU3Check=n ;!!! This must be used to ensure that raw source file is generated before compilation (because $bSetErrLine is True) #AutoIt3Wrapper_Run_Before=%autoitdir%\AutoIt3.exe "%in%" /BC_Strip #AutoIt3Wrapper_Run_After=%autoitdir%\AutoIt3.exe /AutoIt3ExecuteLine "FileDelete('%scriptdir%\OAER_RAW_SRC.tmp')" #pragma compile(Stripper, False) #include 'OnAutoItErrorRegister.au3' _OnAutoItErrorRegister('_MyErrorHandler', '', '', False, True) ;We deliberately make an array bounding error and call the error! Dim $aArr[1] MsgBox(0, '', $aArr[1]) Func _MyErrorHandler($sScriptPath, $iScriptLine, $sErrDesc, $vParams, $hBitmap) ;Restart the application Local $sMessage = StringFormat('SCRIPT FILE:\n%s\n\nSCRIPT ERROR LINE:\n%s\n\nERROR DESCRIPTION:\n%s', $sScriptPath, $iScriptLine, $sErrDesc) If StringInStr($CmdLineRaw, '/ErrorStdOut') Then If FileExists(@WindowsDir & "\Media\chord.wav") Then SoundPlay(@WindowsDir & "\Media\chord.wav") Else DllCall('user32.dll', 'int', 'MessageBeep', 'int', 0x00000010) EndIf EndIf If MsgBox(BitOR($MB_SYSTEMMODAL, $MB_YESNO), 'Crash recieved!', 'Restart application?' & @CRLF & @CRLF & $sMessage) <> 6 Then Return EndIf Local $sRunLine = @AutoItExe & ' "' & @ScriptFullPath & '"' If @Compiled Then $sRunLine = @ScriptFullPath EndIf Run($sRunLine, @ScriptDir) EndFunc Download: OnAutoItErrorRegister.zip (Counter: ) Screenshot: ChangeLog: Initial idea by jennico: Author(s): G.Sandler (MrCreatoR), jennico Notes: The UDF can not handle crashes that triggered by memory leaks, such as DllCall crashes, "Recursion level has been exceeded..." (when using hook method ($bUseStdOut = False)).When using StdOut method ($bUseStdOut = True), CUI not supported, and additional process executed to allow monitor for errors.After using _OnAutoItErrorUnRegister when $bUseStdOut = True, standard AutoIt error message will not be displayed on following syntax error.To use the "Send bug report" feature, there is need to fill related parameters (variables) under the «User Variables» section in UDF file (check the comments of these variables), or just build your own user function.[If $bSetErrLine is True...] Script must be executed before compilation (after any change in it), or use '#AutoIt3Wrapper_Run_Before=%autoitdir%\AutoIt3.exe "%in%" /BC_Strip' in your main script. Do NOT use Au3Stripper when compiling the main script if you want correct error line detection for compiled script. To get correct code line for compiled script, the script is transformed to raw source (merging includes) and FileInstall'ed when it's needed (on error), therefore, the script is available in temp dir for few moments (when error is triggered), although it's crypted, but developer should ensure that his script is more protected. [If $bSetErrLine is False...] Use supplied GetErrLineCode.au3 to get proper error line code by line number from error that was triggered in compiled script.
    1 point
  2. Today this link: https://www.autoitscript.com/autoit3/files/beta/autoit/archive/sqlite/sqlite3.dll don't work. Tested from 3 different DSL connections. So the standard _SQLite_Startup has problems. I have modified my scripts to fileinstall sqlite3.dll locally and use that copy when this happens. Someone confirms this situation ?
    1 point
  3. Hey! Yesterday I started making a small game just 4 fun, but it's very buggy. The way I made it check the collisions and jump off blocks etc is probably not the best way to do it, so it would be great if anyone got any suggestions as to how to improve the collision checks, and/or just what's making it buggy. #Include <GuiconstantsEx.au3> #Include <GDIPlus.au3> HotKeySet("{ESC}", "Terminate") HotKeySet("{SPACE}", "StartJump") #Region Gui $WinWidth=500 $WinHeight=400 $hGUI=GUICreate("", $WinWidth, $WinHeight) GUISetState() #EndRegion #Region Graphics $GDI_QUALITY=2 _GDIPlus_Startup() $GDI_GRAPHICS=_GDIPlus_GraphicsCreateFromHWND($hGUI) $GDI_BITMAP=_GDIPlus_BitmapCreateFromGraphics($WinWidth, $WinHeight, $GDI_GRAPHICS) $GDI_BACKBUFFER=_GDIPlus_ImageGetGraphicsContext($GDI_BITMAP) _GDIPlus_GraphicsSetSmoothingMode($GDI_BACKBUFFER, $GDI_QUALITY) _GDIPlus_GraphicsClear($GDI_BACKBUFFER) $GDI_BRUSH_BALL=_GDIPlus_BrushCreateSolid() #EndRegion #Region GraphicObjects Dim $Obj[1][4] $Obj_Num=0 $SolidBrush=_GDIPlus_BrushCreateSolid() Solid(125, 375, 125) Solid(200, 350, 50, 25) Solid(300, 325, 50, 50) Solid(375, 325, 25, 50) Solid(425, 300, 75, 50) Solid(300, 225, 150, 25) Solid(450, 250) #EndRegion #Region GameVars $BallDirection=1 $BallWidth=20 $BallHeight=20 $BallSpeed=1 $BallSpeedY=0 $BallPosX_0=0 $BallPosX=$BallPosX_0 $BallPosY_Start=$WinHeight-$BallHeight $BallPosY_0=300 $BallPosY=$BallPosY_0 $SurfaceCount=0 $Jump=False $JumpHeight=350 $JumpSoon=False #EndRegion #Region Quality $QualityTimer=TimerInit() $QualityCount=0 $QualityFPS=60 $QualitySleep=2000 #EndRegion While 1 GetNewBallPos() _GDIPlus_GraphicsClear($GDI_BACKBUFFER, 0xFFFFFFFF) DrawObjects() MoveBall() _GDIPlus_GraphicsDrawImageRect($GDI_GRAPHICS, $GDI_BITMAP, 0, 0, $WinWidth, $WinHeight) Gravity() QualityCheck() USleep($QualitySleep) WEnd Func Solid($_SolidPosX, $_SolidPosY, $_SolidWidth=25, $_SolidHeight=25, $_SolidBrush=$SolidBrush) ReDim $Obj[$Obj_Num+1][4] $Obj[$Obj_Num][0]=$_SolidPosX $Obj[$Obj_Num][1]=$_SolidPosY $Obj[$Obj_Num][2]=$_SolidWidth $Obj[$Obj_Num][3]=$_SolidHeight _GDIPlus_GraphicsDrawRect($GDI_GRAPHICS, $_SolidPosX, $_SolidPosY, $_SolidWidth, $_SolidHeight, $_SolidBrush) _GDIPlus_GraphicsDrawImageRect($GDI_GRAPHICS, $GDI_BITMAP, 0, 0, $WinWidth, $WinHeight) $Obj_Num+=1 EndFunc Func DrawObjects() For $1=0 To $Obj_Num-1 _GDIPlus_GraphicsFillRect($GDI_BACKBUFFER, $Obj[$1][0], $Obj[$1][1], $Obj[$1][2], $Obj[$1][3], $SolidBrush) Next EndFunc Func GetNewBallPos() If $BallDirection=1 And SurfaceRight() Then $BallDirection=2 If $BallDirection=2 And SurfaceLeft() Then $BallDirection=1 Switch $BallDirection Case 1 $BallPosX+=$BallSpeed Case 2 $BallPosX-=$BallSpeed EndSwitch EndFunc Func MoveBall() _GDIPlus_GraphicsFillEllipse($GDI_BACKBUFFER, $BallPosX, $BallPosY, $BallWidth, $BallHeight, $GDI_BRUSH_BALL) EndFunc Func SurfaceRight() If $BallPosX>=$WinWidth-$BallWidth Then Return True For $1=0 To $Obj_Num-1 If $Obj[$1][0]+$Obj[$1][2]/10>$BallPosX+$BallWidth And $BallPosX+$BallWidth>=$Obj[$1][0] And $Obj[$1][1]<$BallPosY+$BallHeight And $BallPosY<$Obj[$1][1]+$Obj[$1][3] Then Return True Next EndFunc Func SurfaceLeft() If $BallPosX<=$BallPosX_0 Then Return True For $1=0 To $Obj_Num-1 If $Obj[$1][0]+$Obj[$1][2]>=$BallPosX And $BallPosX>=$Obj[$1][0]+$Obj[$1][2]-$Obj[$1][2]/10 And $Obj[$1][1]<$BallPosY+$BallHeight And $BallPosY<$Obj[$1][1]+$Obj[$1][3] Then Return True Next EndFunc Func SurfaceUnder() If $Jump=True Then Return False If $BallPosY>=$WinHeight-$BallHeight Then $BallPosY=$WinHeight-$BallHeight $BallPosY_0=$WinHeight-$BallHeight Return True EndIf For $1=0 To $Obj_Num-1 If $BallPosX+$BallWidth>=$Obj[$1][0] And $BallPosX<=$Obj[$1][0]+$Obj[$1][2] And $BallPosY+$BallHeight>=$Obj[$1][1] And $BallPosY+$BallHeight<$Obj[$1][1]+$Obj[$1][3]/10 Then $BallPosY_0=$BallPosY Return True EndIf Next EndFunc Func SurfaceOver() For $1=0 To $Obj_Num-1 If $BallPosX+$BallWidth>=$Obj[$1][0] And $BallPosX<=$Obj[$1][0]+$Obj[$1][2] And $BallPosY<=$Obj[$1][1]+$Obj[$1][3] And $BallPosY>$Obj[$1][1]+$Obj[$1][3]-$Obj[$1][3]/10 Then Return True Next EndFunc Func StartJump() If SurfaceUnder() Then $Jump=True $BallPosY_0=$BallPosY $BallSpeedY=$JumpHeight $JumpSoon=False Else $JumpSoon=True EndIf EndFunc Func Gravity() If $BallSpeedY>0 And SurfaceOver() = True Then $BallSpeedY=0 $SurfaceCount=0 $BallPosY_0=$BallPosY EndIf If SurfaceUnder() Then $SurfaceCount=0 $BallSpeedY=0 $BallPosY_0=$BallPosY If Not $JumpSoon=True Then Return Else StartJump() EndIf EndIf $SurfaceCount+=1 $Jump=False $BallPosY=$BallPosY_0-($BallSpeedY*$SurfaceCount+1/2*-9.81*$SurfaceCount^2)*0.01 EndFunc Func QualityCheck() $QualityCount+=1 If $QualityCount=$QualityFPS Then $QualitySleep+=(1000-TimerDiff($QualityTimer))/$QualityFPS*100 $QualityCount=0 $QualityTimer=TimerInit() EndIf EndFunc Func USleep($iUsec, $hDLL = "ntdll.dll") Local $hStruct = DllStructCreate("int64") DllStructSetData($hStruct, 1, -1 * ($iUsec * 10)) DllCall($hDLL, "dword", "ZwDelayExecution", "int", 0, "ptr", DllStructGetPtr($hStruct)) EndFunc Func Terminate() _GDIPlus_BrushDispose($SolidBrush) _GDIPlus_BrushDispose($GDI_BRUSH_BALL) _GDIPlus_GraphicsDispose($GDI_GRAPHICS) _GDIPlus_ImageDispose($GDI_BITMAP) _GDIPlus_Shutdown() Exit EndFunc Edit: Current progress: #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Add_Constants=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <WindowsConstants.au3> #Include <GuiconstantsEx.au3> #Include <GDIPlus.au3> #include <WinAPIGdi.au3> #include <Screencapture.au3> #Include <ButtonConstants.au3> #include <File.au3> #include <GuiConstants.au3> #Include <Crypt.au3> HotKeySet("{ESC}", "Terminate") #Region Gui $PictureDir=@ScriptDir & "\JuegoData\" $WinWidth=500 $WinHeight=400 $hGUI=GUICreate("", $WinWidth, $WinHeight, -1, -1, $WS_POPUPWINDOW) GUISetState() Dim $Button[17] #EndRegion #Region Graphics $GDI_QUALITY=2 _GDIPlus_Startup() $GDI_GRAPHICS=_GDIPlus_GraphicsCreateFromHWND($hGUI) $GDI_BITMAP=_GDIPlus_BitmapCreateFromGraphics($WinWidth, $WinHeight, $GDI_GRAPHICS) $GDI_BACKBUFFER=_GDIPlus_ImageGetGraphicsContext($GDI_BITMAP) _GDIPlus_GraphicsSetSmoothingMode($GDI_BACKBUFFER, $GDI_QUALITY) _GDIPlus_GraphicsClear($GDI_BACKBUFFER) $GDI_BRUSH_BALL=_GDIPlus_BrushCreateSolid() #EndRegion #Region GraphicObjects Dim $Obj[1][14] Dim $Text[1][5] $Text_Num=0 $Obj_Num=0 Dim $Obj_DirectionX[1] Dim $Obj_DirectionY[1] Dim $SolidBrush[20] $SolidBrush[0]=_GDIPlus_BrushCreateSolid() $SolidBrush[1]=_GDIPlus_BrushCreateSolid(0xFF00FF00) $SolidBrush[2]=_GDIPlus_BrushCreateSolid(0xFFFF0000) $SolidBrush[3]=_GDIPlus_BrushCreateSolid(0xFF00FFFF) $SolidBrush[4]=_GDIPlus_BrushCreateSolid(0xFFddad19) $SolidBrush[5]=_GDIPlus_BrushCreateSolid(0xFF004400) $SolidBrush[11]=_GDIPlus_BrushCreateSolid(0xFFFF9900) $SolidBrush[12]=_GDIPlus_BrushCreateSolid(0xFF00FFFF) $SolidBrush[13]=_GDIPlus_BrushCreateSolid(0xFF0000FF) $SolidBrush[14]=_GDIPlus_BrushCreateSolid(0xFF734021) Dim $VanishBrush[1] Dim $EpicBrush[3] $Brush=1 $EpicBrush[0]=_GDIPlus_BrushCreateSolid(0xFFc03430) $EpicBrush[1]=_GDIPlus_BrushCreateSolid(0xFFf8cf46) $EpicBrush[2]=_GDIPlus_BrushCreateSolid(0xFF367341) #EndRegion #Region GameVars Dim $FileLineData[0] $TakeScreenshot=False $GoToMenu=False $WinActive=True Dim $Vanish[1] $BrownStopCount=0 $BrownStop=False $BallDirection=1 $BallWidth=20 $BallHeight=20 $BallSpeed=1 $BallSpeedY=0 $BallPosX_0=0 $BallPosX=$BallPosX_0 $BallPosY_Start=$WinHeight-$BallHeight $BallPosY_0=375 $BallPosY=$BallPosY_0 $SurfaceCount=0 $Jump=False $JumpHeight=350 $JumpSoon=False $JumpSoonTimer=TimerInit() $IsSqueezed=0 $SurfaceMove=0 $Level=1 $BallPosYDiff=0 $LastBallPosY=$BallPosY $ActivePowerup=0 $ExtraJumpActive=0 $TeleTimer=TimerInit() Dim $VanishTimer[1] #EndRegion Menu() #Region Quality $QualityTimer=TimerInit() $QualityCount=0 $QualityFPS=60 $QualitySleep=2000 $USleepTimer=TimerInit() #EndRegion While 1 CheckActive() GetNewBallPos() _GDIPlus_GraphicsClear($GDI_BACKBUFFER, 0xFFFFFFFF) CheckVanish() DrawText() DrawObjects() MoveBall() _GDIPlus_GraphicsDrawImageRect($GDI_GRAPHICS, $GDI_BITMAP, 0, 0, $WinWidth, $WinHeight) If $TakeScreenshot=True Then TakeSnapShot() Gravity() QualityCheck() $ScriptPos=0 If $GoToMenu=True Then GoToMenu() USleep($QualitySleep) $ScriptPos=1 WEnd ;================================================================================= ;============================== OBJECT DESCRIPTION =============================== ;==============================--------------------=============================== ;============ Solid( Type, X, Y, [Width, Height, X2, Y2, Speed) ================== ;==============================--------------------=============================== ;============================== TYPES ============================== ;============================== 0 = Black Solid ============================== ;============================== 1 = Green Goal ============================== ;============================== 2 = Red Fail ============================== ;============================== 3 = Cyan Lock ============================== ;============================== 4 = Gold Sticky ============================== ;============================== 5 = Green Vanish ============================== ;============================== 11 = Extra Jump ============================== ;============================== 12 = Cyan Key ============================== ;============================== 13 = Blue Teleport ============================== ;============================== 14 = Brown Stop ============================== ;================================================================================= Func LevelFromTxt($_Level) $Level=$_Level $FileDir=@ScriptDir & "\JuegoData\Level" & $_Level & ".txt" $FileLines=_FileCountLines($FileDir) $FileOpen=FileOpen($FileDir) For $1=1 To $FileLines $FileData=FileReadLine($FileOpen, $1) StringReplace($FileData, ",", ",") $FileDataLen=@extended If StringLeft($FileData, 5)="Solid" Then $FileMode=1 If StringLeft($FileData, 4)="Text" Then $FileMode=0 $FileData=StringTrimLeft($FileData, 5+$FileMode) ReDim $FileLineData[0] ReDim $FileLineData[9] For $2=0 To $FileDataLen $FileLen=StringInStr($FileData, ",") $FileLineData[$2]=StringLeft($FileData, $FileLen-1) $FileData=StringTrimLeft($FileData, $FileLen) Next $FileLineData[$FileDataLen]=StringTrimRight($FileData, 1) If $FileMode=1 Then If $FileLineData[3]="" Then $FileLineData[3]=25 If $FileLineData[4]="" Then $FileLineData[4]=25 If $FileLineData[5]="" Then $FileLineData[5]=$FileLineData[1] If $FileLineData[6]="" Then $FileLineData[6]=$FileLineData[2] If $FileLineData[7]="" Then $FileLineData[7]=100 If $FileLineData[8]="" Then $FileLineData[8]=$SolidBrush[$FileLineData[0]] Solid($FileLineData[0], $FileLineData[1], $FileLineData[2], $FileLineData[3], $FileLineData[4], $FileLineData[5], $FileLineData[6], $FileLineData[7], $FileLineData[8]) ElseIf $FileMode=0 Then If $FileLineData[3]="" Then $FileLineData[3]=10 If $FileLineData[4]="" Then $FileLineData[4]="Arial" Text($FileLineData[0], $FileLineData[1], $FileLineData[2], $FileLineData[3], $FileLineData[4]) EndIf Next EndFunc Func Level8() $Level=8 Solid(0, 100, -50, 25, 450) Solid(0, 225, -50, 25, 425) Solid(0, 350, -50, 25, 425) Solid(3, 225, 375, 25) Solid(3, 350, 375, 25) Solid(13, 0, 310, 25, 15, 75, 310, 400) Solid(13, 0, 200, 25, 15, 75, 200, 200) Solid(2, 0, 290, 100, 15) Solid(13, 0, 270, 25, 15, 75) Solid(13, 0, 100, 25, 15) Solid(0, 0, 150, 50, 10, 50, 150, 80) Solid(0, 0, 85, 25, 15) Solid(13, 80, 0, 15, 25, 80, 25) Solid(13, 130, 0, 15, 25) Solid(2, 50, 75, 50, 15) Solid(2, 125, 50) Solid(0, 150, 50) Solid(2, 200, 50) Solid(0, 200, 128) Solid(2, 170, 128, 30) Solid(0, 125, 75, 10, 90) Solid(0, 150, 200, 50) Solid(2, 200, 200) Solid(0, 150, 250) Solid(11, 200, 275, 20, 20) Solid(2, 150, 275) Solid(2, 125, 300, 100) Solid(13, 125, 285, 25, 15) Solid(13, 250, 275, 25, 15) Solid(5, 250, 325, 50) Solid(2, 250, 350, 100) Solid(0, 275, 265, 25, 32) Solid(2, 250, 250, 50, 15) Solid(5, 325, 275) Solid(5, 250, 225) Solid(5, 250, 170) Solid(5, 325, 180) Solid(5, 300, 100) Solid(5, 325, 115) Solid(5, 250, 50) Solid(13, 335, 0, 15, 25) Solid(13, 375, 0, 15, 25) Solid(2, 375, 75, 40) Solid(5, 415, 75) Solid(2, 440, 75, 60) Solid(14, 425, 0, 20, 20) Solid(11, 450, 25, 20, 20) Solid(5, 375, 190, 25, 20) Solid(2, 400, 190, 40, 20) Solid(0, 440, 100, 20, 110) Solid(11, 417, 125, 20, 20) Solid(14, 375, 105, 20, 20) Solid(14, 375, 160, 20, 20) Solid(2, 375, 275) Solid(11, 400, 275, 20, 20) Solid(11, 450, 250, 20, 20) Solid(11, 472, 200, 20, 20) Solid(14, 472, 150, 20, 20) Solid(12, 472, 100, 20, 20) Solid(11, 472, 310, 20, 20) Solid(2, 425, 350, 75) Solid(1, 150, 350, 50) EndFunc Func Level7() $Level=7 ;~ $BallPosX_0=0 ;~ $BallPosX=225 ;~ $BallPosY_0=0 ;~ $BallPosY=$BallPosY_0 ;~ $BallDirection=2 Solid(2, 0, 225, 75) Solid(2, 75, 225, 25, 50) Solid(0, 75, 275, 25, 75) Solid(1, 0, 250, 75) Solid(2, 150, 325, 100) Solid(2, 275, 375) Solid(2, 250, 300) Solid(2, 275, 275, 50) Solid(2, 325, 300) Solid(2, 350, 375) Solid(2, 350, 275, 50) Solid(2, 400, 275, 25, 50) Solid(2, 450, 375) Solid(0, 475, 375) Solid(11, 475, 350, 20, 20) Solid(2, 425, 250, 75) Solid(3, 0, 325, 75) Solid(0, 150, 300, 100) Solid(2,100, 225, 125) Solid(0, 300, 250) Solid(0, 400, 250) Solid(2, 400, 125, 25, 75) Solid(0, 475, 200) Solid(0, 425, 150) Solid(0, 375, 125) Solid(11, 325, 125, 20, 20) Solid(2, 250, 75, 25, 75) Solid(2, 200, 150, 25, 75) Solid(0, 150, 200, 50) Solid(11, 50, 200, 20, 20) Solid(11, 0, 125, 20, 20) Solid(11, 50, 75, 20, 20) Solid(11, 100, 75, 20, 20) Solid(11, 225, 75, 20, 20) Solid(11, 300, 50, 20, 20) Solid(11, 450, 50, 20, 20) Solid(11, 450, 0, 20, 20) Solid(12, 475, 0, 20, 20) Solid(11, 400, 0, 20, 20) EndFunc Func Level6() $Level=6 Solid(0, 100, 100, 25, 300) Solid(0, 75, 375) Solid(0, 0, 325) Solid(0, 50, 275) Solid(0, 50, 200) Solid(0, 0, 225) Solid(0, 50, 140) Solid(0, 50, 75, 75) Solid(0, 0, 75) Solid(2, 75, 0, 25, 75) Solid(13, 55, 25, 15, 25) Solid(13, 105, 25, 15, 25) Solid(0, 150, -25, 25, 375) Solid(0, 300, 50, 25, 350) Solid(4, 225, 300, 75, 25, 225, 400, 400) Solid(0, 175, 200, 50, 25, 175, 300, 200) Solid(0, 225, 225, 75) Solid(0, 175, 100, 50, 25, 175, 200, 200) Solid(0, 225, 50, 75, 25, 225, 125, 400) Solid(0, 325, 50, 150) Solid(2, 350, 25, 25, 25, 425, 25, 200) Solid(0, 375, 175, 75) Solid(4, 450, 175, 50) Solid(2, 325, 75, 25, 25, 425) Solid(2, 375, 150, 25, 25, 400) Solid(0, 450, 75, 25, 50) Solid(0, 325, 225, 50, 50) Solid(0, 375, 250, 50) Solid(4, 425, 250) Solid(0, 450, 250, 50) Solid(13, 425, 200, 25, 15) Solid(13, 325, 275, 25, 15, 475) Solid(2, 325, 385, 175, 15) Solid(1, 325, 365, 50, 15, 450, 365, 200) EndFunc Func Level5() $Level=5 Solid(2, 100, 375) Solid(2, 225, 375) Solid(0, 250, 375, 50) Solid(2, 300, 375, 50) Solid(0, 350, 375) Solid(2, 375, 375) Solid(0, 400, 350, 100, 50) Solid(0, 450, 300, 25) Solid(0, 350, 250, 50) Solid(11, 363, 225, 20, 20) Solid(2, 300, 250, 50) Solid(0, 250, 275, 50) Solid(2, 175, 250, 75) Solid(2, 175, 225, 50) Solid(0, 125, 250, 50) Solid(2, 100, 100, 25, 100) Solid(11, 125, 225, 20, 20) Solid(11, 25, 225, 20, 20) Solid(11, 25, 175, 20, 20) Solid(11, 50, 125, 20, 20) Solid(11, 50, 75, 20, 20) Solid(0, 175, 100, 50) Solid(11, 300, 100, 20, 20) Solid(11, 375, 100, 20, 20) Solid(11, 425, 75, 20, 20) Solid(1, 475, 50) EndFunc Func Level4() $Level=4 Solid(0, 0, 400, 500) Solid(0, 125, 375, 125) Solid(0, 200, 350, 50, 25) Solid(0, 300, 325, 50, 50) Solid(0, 375, 325, 25, 50) Solid(0, 425, 300, 75, 50) Solid(0, 300, 225, 150, 25) Solid(0, 450, 250) Solid(0, 225, 250) Solid(0, 150, 200) Solid(0, 0, 300, 100) Solid(0, 50, 150, 25, 100) Solid(0, 25, 250) Solid(0, 0, 200) Solid(0, 425, 175, 75) Solid(0, 425, 125) Solid(0, 350, 125, 50) Solid(0, 275, 125) Solid(0, 150, 100, 75) Solid(0, 0, 100) Solid(0, 50, 50) Solid(0, 100, 0, 50) Solid(0, 150, 25, 75) Solid(0, 275, 25, 50) Solid(0, 375, 25, 125) Solid(1, 475, 0) EndFunc Func Level3() $Level=3 Text("Blocks can move!", 25, 300) Solid(4, 100, 375, 100) Solid(2, 200, 375, 175) Solid(0, 200, 350, 75, 25, 300, 350, 200) Solid(0, 375, 175, 125, 25, 375, 375, 200) Solid(0, 275, 175, 100) Solid(3, 75, 175, 200) Solid(0, 0, 175, 75) Solid(12, 0, 150, 20, 20) Solid(0, 100, 225, 75) Solid(1, 225, 200, 50) EndFunc Func Level2() $Level=2 Solid(0, 50, 375, 50) Solid(0, 125, 325, 100, 50) Solid(0, 250, 325, 100, 50) Solid(0, 400, 325, 75, 50) Solid(0, 0, 275, 100) Solid(0, 150, 225, 50) Solid(0, 250, 175, 75) Solid(0, 400, 200, 75) Solid(1, 475, 200) Text("Hit enter to restart. Hit esc to exit.", 300, 0, 8) EndFunc Func Level1() $Level=1 Solid(0, 100, 375, 100) Solid(2, 200, 375) Solid(0, 225, 375, 75) Solid(4, 300, 375, 125) Solid(13, 425, 385, 75, 15) Solid(13, 0, 125, 75, 15) Solid(0, 0, 250, 175) Solid(11, 100, 225, 20, 20) Solid(2, 175, 250, 75) Solid(0, 250, 250, 175) Solid(12, 320, 225, 20, 20) Solid(3, 375, 125, 50, 125) Solid(13, 425, 255, 75, 15) Solid(13, 0, 0, 75, 15) Solid(0, 0, 100, 125) Solid(5, 125, 100) Solid(5, 150, 100) Solid(5, 175, 100) Solid(5, 200, 100) Solid(0, 225, 100, 275) Solid(14, 300, 75, 20, 20) Solid(1, 450, 50, 50, 50) Text("Press up to jump", 0, 325, 8) Text("Avoid red", 180, 325, 8) Text("Sticky", 335, 325, 8) Text("Teleport", 435, 325, 8) Text("Jump in the air! Hit space to use", 15, 200, 8) Text("Lock and key", 285, 200, 8) Text("These vanish!", 130, 50, 8) Text("Use to pause moving", 240, 50, 8) Text("Hit to win!", 435, 20, 8) EndFunc Func Solid($_SolidType, $_SolidPosX, $_SolidPosY, $_SolidWidth=25, $_SolidHeight=25, $_SolidPosX_2=$_SolidPosX, $_SolidPosY_2=$_SolidPosY, $_SolidSpeed=100, $_SolidBrush=$SolidBrush[$_SolidType]) ReDim $Obj[$Obj_Num+1][14] ReDim $VanishTimer[$Obj_Num+1] ReDim $VanishBrush[$Obj_Num+1] ReDim $Vanish[$Obj_Num+1] $Obj[$Obj_Num][0]=$_SolidPosX $Obj[$Obj_Num][1]=$_SolidPosY $Obj[$Obj_Num][2]=$_SolidWidth $Obj[$Obj_Num][3]=$_SolidHeight $Obj[$Obj_Num][4]=$_SolidPosX_2 $Obj[$Obj_Num][5]=$_SolidPosY_2 $Obj[$Obj_Num][6]=Sqrt(($_SolidPosX_2-$_SolidPosX)^2+($_SolidPosY_2-$_SolidPosY)^2)/$_SolidSpeed If $_SolidPosX_2<>$_SolidPosX Then $Obj[$Obj_Num][7]=1 If $_SolidPosY_2<>$_SolidPosY Then $Obj[$Obj_Num][8]=1 If $_SolidPosX_2<>$_SolidPosX Then $Obj[$Obj_Num][9]=$_SolidPosX If $_SolidPosY_2<>$_SolidPosY Then $Obj[$Obj_Num][10]=$_SolidPosY $Obj[$Obj_Num][11]=$_SolidBrush $Obj[$Obj_Num][12]=$_SolidType $Obj[$Obj_Num][13]=1 If $_SolidType=5 Then $VanishBrush[$Obj_Num]=_GDIPlus_BrushCreateSolid(0xFF004400) If $_SolidType=5 Then $Vanish[$Obj_Num]=99 ReDim $Obj_DirectionX[$Obj_Num+1] ReDim $Obj_DirectionY[$Obj_Num+1] $Obj_DirectionX[$Obj_Num]=1 $Obj_DirectionY[$Obj_Num]=1 $Obj_Num+=1 EndFunc Func Text($_TextData, $_TextPosX, $_TextPosY, $_TextSize=10, $_TextFont="Arial") ReDim $Text[$Text_Num+1][5] $Text[$Text_Num][0]=$_TextData $Text[$Text_Num][1]=$_TextPosX $Text[$Text_Num][2]=$_TextPosY $Text[$Text_Num][3]=$_TextSize $Text[$Text_Num][4]=$_TextFont $Text_Num+=1 EndFunc Func DrawText() For $1=0 To $Text_Num-1 _GDIPlus_GraphicsDrawString($GDI_BACKBUFFER, $Text[$1][0], $Text[$1][1], $Text[$1][2], $Text[$1][4], $Text[$1][3]) Next EndFunc Func DrawObjects() For $1=0 To $Obj_Num-1 If $Obj[$1][7]=1 Then ;;;Turn Object Vertically $Obj[$1][0]+=$Obj[$1][6]*$Obj_DirectionX[$1] If $Obj[$1][0]=$Obj[$1][4] Then $Obj_DirectionX[$1]*=-1 If $Obj[$1][0]=$Obj[$1][9] Then $Obj_DirectionX[$1]*=-1 EndIf If $Obj[$1][8]=1 Then ;;;Turn Object Horisontally $Obj[$1][1]+=$Obj[$1][6]*$Obj_DirectionY[$1] If $Obj[$1][1]=$Obj[$1][5] Then $Obj_DirectionY[$1]*=-1 If $Obj[$1][1]=$Obj[$1][10] Then $Obj_DirectionY[$1]*=-1 EndIf If $Obj[$1][12]>10 Then If $Obj[$1][13]<>0 Then _GDIPlus_GraphicsFillEllipse($GDI_BACKBUFFER, $Obj[$1][0], $Obj[$1][1], $Obj[$1][2], $Obj[$1][3], $Obj[$1][11]) Else If $Obj[$1][13]<>0 Then _GDIPlus_GraphicsFillRect($GDI_BACKBUFFER, $Obj[$1][0], $Obj[$1][1], $Obj[$1][2], $Obj[$1][3], $Obj[$1][11]) EndIf Next EndFunc Func GetNewBallPos() If $BrownStop=True Then ;;;Brown Stop $BrownStopCount+=1 If $BrownStopCount>50 Then $BrownStop=False Return EndIf $IsSqueezed=0 If SurfaceRight() Then $BallDirection=2 If SurfaceLeft() Then $BallDirection=1 If $IsSqueezed=2 Then LoseGame() Switch $BallDirection Case 1 $BallPosX+=$BallSpeed Case 2 $BallPosX-=$BallSpeed EndSwitch EndFunc Func CheckVanish() For $1=0 To $Obj_Num-1 If $Obj[$1][12]=5 Then If $Obj[$1][13]=2 Then $Vanish[$1]-=2 _GDIPlus_BrushSetSolidColor($VanishBrush[$1], '0x' & $Vanish[$1] & '004400') $Obj[$1][11]=$VanishBrush[$1] If $Vanish[$1]<10 Then $Obj[$1][13]=0 $Vanish[$1]=99 $VanishTimer[$1]=TimerInit() EndIf ElseIf $Obj[$1][13]=0 And TimerDiff($VanishTimer[$1])>2000 Then $VanishTimer[$1]=TimerInit() If PointInSquare($BallPosX+$BallWidth, $BallPosY, $Obj[$1][0], $Obj[$1][1], $Obj[$1][0]+$Obj[$1][2], $Obj[$1][1]+$Obj[$1][3], -2, 1, 0) = False Then If PointInSquare($BallPosX+$BallWidth, $BallPosY+$BallHeight, $Obj[$1][0], $Obj[$1][1], $Obj[$1][0]+$Obj[$1][2], $Obj[$1][1]+$Obj[$1][3], -2, 1, 0) = False Then If PointInSquare($BallPosX, $BallPosY+$BallHeight, $Obj[$1][0], $Obj[$1][1], $Obj[$1][0]+$Obj[$1][2], $Obj[$1][1]+$Obj[$1][3], -2, 1, 0) = False Then If PointInSquare($BallPosX, $BallPosY, $Obj[$1][0], $Obj[$1][1], $Obj[$1][0]+$Obj[$1][2], $Obj[$1][1]+$Obj[$1][3], -2, 1, 0) = False Then _GDIPlus_BrushSetSolidColor($VanishBrush[$1], 0xFF004400) $Obj[$1][13]=1 $Obj[$1][11]=$SolidBrush[5] EndIf EndIf EndIf EndIf EndIf EndIf Next EndFunc Func MoveBall() Switch $Brush Case 1 _GDIPlus_GraphicsFillEllipse($GDI_BACKBUFFER, $BallPosX, $BallPosY, $BallWidth, $BallHeight, $GDI_BRUSH_BALL) Case 2 _GDIPlus_GraphicsFillEllipse($GDI_BACKBUFFER, $BallPosX, $BallPosY, $BallWidth, $BallHeight, $EpicBrush[0]) _GDIPlus_GraphicsFillEllipse($GDI_BACKBUFFER, $BallPosX+$BallWidth/8, $BallPosY+$BallHeight/8, $BallWidth-$BallWidth/4, $BallHeight-$BallHeight/4, $EpicBrush[1]) _GDIPlus_GraphicsFillEllipse($GDI_BACKBUFFER, $BallPosX+$BallWidth/4, $BallPosY+$BallHeight/4, $BallWidth-$BallWidth/2, $BallHeight-$BallHeight/2, $EpicBrush[2]) EndSwitch EndFunc Func WinGame() $Level+=1 $CryptKey="Juego" If $Level<9 And _Crypt_DecryptData(IniRead(@ScriptDir & "\JuegoData\CL.ini", "1", "1", ""), "Juego", $CALG_AES_256)<$Level Then IniWrite(@ScriptDir & "\JuegoData\CL.ini", "1", "1", _Crypt_EncryptData($Level, $CryptKey, $CALG_AES_256)) $ActivePowerup=0 $ExtraJumpActive=1 _GDIPlus_BrushSetSolidColor($GDI_BRUSH_BALL, 0xFF000000) $Jump=0 $JumpSoon=0 $SurfaceCount=0 $BallPosY=$BallPosY_Start $BallPosX=$BallPosX_0 ReDim $Obj[0][0] ReDim $Obj[1][14] ReDim $Text[0][0] ReDim $Text[1][5] $Obj_Num=0 $Text_Num=0 If $Level<9 Then RunLevel($Level) Else GoToMenu() EndIf $QualityCount=0 $QualityTimer=TimerInit() EndFunc Func LoseGame() For $1=1 To $Obj_Num-1 $Obj[$1][13]=1 $Vanish[$1]=99 _GDIPlus_BrushSetSolidColor($VanishBrush[$1], 0xFF004400) Next $ActivePowerup=0 $ExtraJumpActive=1 $Jump=0 _GDIPlus_BrushSetSolidColor($GDI_BRUSH_BALL, 0xFF000000) $BallPosY=$BallPosY_Start $BallPosX=$BallPosX_0 $SurfaceCount=0 $QualityCount=0 $QualityTimer=TimerInit() EndFunc Func SurfaceRight() If $BallPosX>=$WinWidth-$BallWidth Then Return True For $1=0 To $Obj_Num-1 If PointInSquare($BallPosX+$BallWidth, $BallPosY+$BallHeight/2, $Obj[$1][0], $Obj[$1][1], $Obj[$1][0]+$Obj[$1][2], $Obj[$1][1]+$Obj[$1][3], $Obj[$1][12], $Obj[$1][13], $1) Then If CheckForPowerup($1, $Obj[$1][12], $Obj[$1][13])= True Then Return False If $Obj[$1][7]=1 And $Obj[$1][6]>$BallSpeed Then $BallPosX=$Obj[$1][0]-$BallWidth If $Obj[$1][12]=2 Then LoseGame() If $Obj[$1][12]=1 Then WinGame() $IsSqueezed+=1 Return True EndIf Next EndFunc Func SurfaceLeft() If $BallPosX<=$BallPosX_0 Then Return True For $1=0 To $Obj_Num-1 If PointInSquare($BallPosX, $BallPosY+$BallHeight/2, $Obj[$1][0], $Obj[$1][1], $Obj[$1][0]+$Obj[$1][2], $Obj[$1][1]+$Obj[$1][3], $Obj[$1][12], $Obj[$1][13], $1) Then If CheckForPowerup($1, $Obj[$1][12], $Obj[$1][13])= True Then Return False If $Obj[$1][7]=1 And $Obj[$1][6]>$BallSpeed Then $BallPosX=$Obj[$1][0]+$Obj[$1][2] If $Obj[$1][12]=2 Then LoseGame() If $Obj[$1][12]=1 Then WinGame() $IsSqueezed+=1 Return True EndIf Next EndFunc Func SurfaceUnder() If $ExtraJumpActive=1 Or $ExtraJumpActive=2 Then If $ExtraJumpActive=2 Then $ExtraJumpActive=-1 $ExtraJumpActive+=1 Return True EndIf For $1=0 To $Obj_Num-1 If PointInSquare($BallPosX+$BallWidth-3, $BallPosY+$BallHeight+1, $Obj[$1][0], $Obj[$1][1], $Obj[$1][0]+$Obj[$1][2], $Obj[$1][1]+$Obj[$1][3], $Obj[$1][12], $Obj[$1][13], $1) Or PointInSquare($BallPosX+3, $BallPosY+$BallHeight+1, $Obj[$1][0], $Obj[$1][1], $Obj[$1][0]+$Obj[$1][2], $Obj[$1][1]+$Obj[$1][3], $Obj[$1][12], $Obj[$1][13], $1) Then If CheckForPowerup($1, $Obj[$1][12], $Obj[$1][13])= True Then Return False If $Obj[$1][12]=4 Then ;;;Gold Sticky If $BallDirection=1 Then $BallPosX-=0.75 If $BallDirection=2 Then $BallPosX+=0.75 EndIf $BallPosY=$Obj[$1][1]-$BallHeight $BallPosY_0=$BallPosY If $Obj[$1][12]=2 Then LoseGame() If $Obj[$1][12]=1 Then WinGame() Return True EndIf Next If $BallPosY+$BallHeight>=$WinHeight Then $BallPosY=$WinHeight-$BallHeight $BallPosY_0=$WinHeight-$BallHeight Return True EndIf EndFunc Func SurfaceOver() For $1=0 To $Obj_Num-1 If PointInSquare($BallPosX+$BallWidth-5, $BallPosY, $Obj[$1][0], $Obj[$1][1], $Obj[$1][0]+$Obj[$1][2], $Obj[$1][1]+$Obj[$1][3], $Obj[$1][12], $Obj[$1][13], $1) Or PointInSquare($BallPosX+5, $BallPosY, $Obj[$1][0], $Obj[$1][1], $Obj[$1][0]+$Obj[$1][2], $Obj[$1][1]+$Obj[$1][3], $Obj[$1][12], $Obj[$1][13], $1) Then If CheckForPowerup($1, $Obj[$1][12], $Obj[$1][13])= True Then Return False $SurfaceMove=0 If $Obj[$1][12]=2 Then LoseGame() If $Obj[$1][8]=1 Then $BallPosY=$Obj[$1][1]+$Obj[$1][3] $SurfaceMove=1 $SurfaceCount=5 ElseIf $BallPosY<$Obj[$1][1]+$Obj[$1][3]-2 Then $BallPosY=$Obj[$1][1]+$Obj[$1][3] EndIf If $Obj[$1][12]=1 Then WinGame() Return True EndIf Next EndFunc Func CheckForPowerup($__PowerupObjNum, $__PowerupObj, $__PowerupActive) If $__PowerupObj>10 Then If $__PowerupActive=0 Then Return True If $__PowerupObj<>13 Then $Obj[$__PowerupObjNum][13]=0 ActivatePowerup($__PowerupObj, $__PowerupObjNum) Return True EndIf Return False EndFunc Func ActivatePowerup($_PowerupType, $_PowerupObjNum) Switch $_PowerupType Case 11;;Superjump _GDIPlus_BrushSetSolidColor($GDI_BRUSH_BALL, 0xFFFF9900) Case 12;;Cyan Key For $1=0 To $Obj_Num-1 If $Obj[$1][12]=3 And $Obj[$1][13]=1 Then $Obj[$1][13]=0 Next $_PowerupType=$ActivePowerup Case 13;;Teleport If TimerDiff($TeleTimer)>500 Then $TeleLink=-1 If $Obj[$_PowerupObjNum-1][12]<>13 Then $TeleLink=1 $TeleDiffY=$BallPosY-$BallPosY_0 $BallPosX=$Obj[$_PowerupObjNum+$TeleLink][0]+$Obj[$_PowerupObjNum+$TeleLink][2]/2-$BallWidth/2 $BallPosY=$Obj[$_PowerupObjNum+$TeleLink][1]+$Obj[$_PowerupObjNum+$TeleLink][3]/2-$BallHeight/2 $BallPosY_0=$BallPosY-$TeleDiffY $TeleTimer=TimerInit() EndIf $_PowerupType=$ActivePowerup Case 14 _GDIPlus_BrushSetSolidColor($GDI_BRUSH_BALL, 0xFF734021) EndSwitch $ActivePowerup=$_PowerupType EndFunc Func SpendPowerup() Switch $ActivePowerup Case 0 Return Case 11 ;;;EXTRA JUMP $ActivePowerup=0 $ExtraJumpActive=1 $SurfaceCount=0 StartJump() Case 14 ;;;Brown Stop $BrownStop=True $BrownStopCount=0 EndSwitch _GDIPlus_BrushSetSolidColor($GDI_BRUSH_BALL, 0xFF000000) EndFunc Func StartJump() If SurfaceUnder() Then $Jump=True $BallPosY_0=$BallPosY ;~ $BallSpeedY=$JumpHeight $JumpSoon=False Else $JumpSoonTimer=TimerInit() $JumpSoon=True EndIf EndFunc Func Gravity() If SurfaceOver() = True Then $BallSpeedY=0 If $SurfaceMove=0 Then $SurfaceCount=2 $BallPosY_0=$BallPosY EndIf If SurfaceUnder() Then $SurfaceCount=0 $BallSpeedY=0 $BallPosY_0=$BallPosY If $JumpSoon=False And $Jump=False Then Return Else If $JumpSoon=True And TimerDiff($JumpSoonTimer)>150 Then Return $BallSpeedY=$JumpHeight StartJump() $Jump=False EndIf EndIf $SurfaceCount+=1 $BallPosY=$BallPosY_0-($BallSpeedY*$SurfaceCount+1/2*-9.81*$SurfaceCount^2)*0.01 EndFunc Func QualityCheck() $QualityCount+=1 If $QualityCount=$QualityFPS Then $QualitySleep+=(950-TimerDiff($QualityTimer))/$QualityFPS*100 $QualityCount=0 $QualityTimer=TimerInit() EndIf EndFunc Func USleep($iUsec, $hDLL = "ntdll.dll") $iUsec-=TimerDiff($USleepTimer)*100 If $iUsec<0 Then $iUsec=0 Local $hStruct = DllStructCreate("int64") DllStructSetData($hStruct, 1, -1 * ($iUsec * 10)) DllCall($hDLL, "dword", "ZwDelayExecution", "int", 0, "ptr", DllStructGetPtr($hStruct)) $USleepTimer=TimerInit() EndFunc Func PointInSquare($_PointX, $_PointY, $_SquareTopX, $_SquareTopY, $_SquareBottomX, $_SquareBottomY, $_SquareType, $_SquareActive, $_SquareObjNum) If $_SquareActive=0 Then Return False $_SquareDiff=0 If $_SquareType=2 Then $_SquareDiff=2 If $_SquareType>10 Then $_SquareDiff=2 If $_PointX<$_SquareTopX+$_SquareDiff Then Return False If $_PointX>$_SquareBottomX-$_SquareDiff Then Return False If $_PointY<$_SquareTopY+$_SquareDiff Then Return False If $_PointY>$_SquareBottomY-$_SquareDiff Then Return False If $_SquareType = 5 Then $Obj[$_SquareObjNum][13]=2 Return True EndFunc Func TakeSnapShot() If Not FileExists($PictureDir) Then DirCreate($PictureDir) _ScreenCapture_CaptureWnd($PictureDir & "\Temp.bmp", $hGUI, 0, 0, -1, -1, False) $___SnapShotImage = _GDIPlus_ImageLoadFromFile($PictureDir & "\Temp.bmp") $___GC = _GDIPlus_ImageGetGraphicsContext($___SnapShotImage) $___NewBmp = _GDIPlus_BitmapCreateFromGraphics(115,87,$___GC) $___newGC = _GDIPlus_ImageGetGraphicsContext($___NewBmp) _GDIPlus_GraphicsDrawImageRect($___newGC,$___SnapShotImage,0,0,115,87) _GDIPlus_ImageSaveToFile($___newBmp,$PictureDir & "\Level" & $Level & ".bmp") _GDIPlus_GraphicsDispose($___GC) _GDIPlus_GraphicsDispose($___newGC) _GDIPlus_BitmapDispose($___newBmp) _GDIPlus_ImageDispose($___SnapShotImage) FileDelete($PictureDir & "\Temp.bmp") $TakeScreenshot=False EndFunc Func Menu() $Level=0 $ButtonPosX=2 $ButtonPosY=2 For $1=1 To 16 $Button[$1]=GUICtrlCreateButton("", $ButtonPosX, $ButtonPosY, 120, 95, $BS_BITMAP) $ButtonPosX+=125 If $ButtonPosX>500 Then $ButtonPosX=2 $ButtonPosY+=100 EndIf GUICtrlSetImage($Button[$1], $PictureDir & "\Level" & $1 & ".bmp") If _Crypt_DecryptData(IniRead(@ScriptDir & "\JuegoData\CL.ini", "1", "1", ""), "Juego", $CALG_AES_256)<$1 And $1<9 And $1>1 Then GUICtrlSetState($Button[$1], 128) Next While 1 $msg=GUIGetMsg() For $1=1 To 16 Switch $msg ;~ Case $Button[1] ;~ DeleteMenu() ;~ Level1() ;~ Return Case $Button[$1] DeleteMenu() RunLevel($1) Return EndSwitch Next WEnd EndFunc Func RunLevel($_RunLevel) HotKeySet("{UP}", "StartJump") HotKeySet("{SPACE}", "SpendPowerup") HotKeySet("{PRINTSCREEN}", "TakeSnapShot") HotKeySet("{ENTER}", "LoseGame") Switch $_RunLevel Case 1 Level1() Case 2 Level2() Case 3 Level3() Case 4 Level4() Case 5 Level5() Case 6 Level6() Case 7 Level7() Case 8 Level8() Case 9 To 16 $Level=-1 LevelFromTxt($_RunLevel) EndSwitch $TakeScreenshot=True EndFunc Func DeleteMenu() For $1=1 To 16 GUICtrlDelete($Button[$1]) Next $QualityCount=0 $QualityTimer=TimerInit() EndFunc Func GoToMenu() If $ScriptPos=1 Then $GoToMenu=True Return EndIf $GoToMenu=False HotKeySet("{UP}") HotKeySet("{SPACE}") HotKeySet("{PRINTSCREEN}") HotKeySet("{ENTER}") _GDIPlus_GraphicsClear($GDI_BACKBUFFER, 0xFFFFFFFF) _GDIPlus_GraphicsDrawImageRect($GDI_GRAPHICS, $GDI_BITMAP, 0, 0, $WinWidth, $WinHeight) $ActivePowerup=0 $ExtraJumpActive=1 _GDIPlus_BrushSetSolidColor($GDI_BRUSH_BALL, 0xFF000000) $Jump=0 $JumpSoon=0 $SurfaceCount=0 $BallPosY=$BallPosY_Start $BallPosX=$BallPosX_0 ReDim $Obj[0][0] ReDim $Obj[1][14] ReDim $Text[0][0] ReDim $Text[1][5] $Obj_Num=0 $Text_Num=0 $QualityCount=0 $QualityTimer=TimerInit() Menu() EndFunc Func CheckActive() If WinActive($hGUI) Then If $WinActive=False Then HotKeySet("{UP}", "StartJump") HotKeySet("{SPACE}", "SpendPowerup") HotKeySet("{PRINTSCREEN}", "TakeSnapShot") HotKeySet("{ENTER}", "LoseGame") EndIf $WinActive=True Else If $WinActive=True Then HotKeySet("{UP}") HotKeySet("{SPACE}") HotKeySet("{PRINTSCREEN}") HotKeySet("{ENTER}") EndIf $WinActive=False EndIf EndFunc Func Terminate() If $Level<>0 Then GoToMenu() Return EndIf _GDIPlus_BrushDispose($SolidBrush[0]) _GDIPlus_BrushDispose($SolidBrush[1]) _GDIPlus_BrushDispose($SolidBrush[2]) _GDIPlus_BrushDispose($SolidBrush[3]) _GDIPlus_BrushDispose($SolidBrush[4]) _GDIPlus_BrushDispose($SolidBrush[5]) _GDIPlus_BrushDispose($SolidBrush[11]) _GDIPlus_BrushDispose($SolidBrush[12]) _GDIPlus_BrushDispose($SolidBrush[13]) _GDIPlus_BrushDispose($GDI_BRUSH_BALL) _GDIPlus_BrushDispose($VanishBrush) _GDIPlus_GraphicsDispose($GDI_GRAPHICS) _GDIPlus_ImageDispose($GDI_BITMAP) _GDIPlus_Shutdown() Exit EndFunc
    1 point
  4. jchd

    Simple SQL Query Tool

    ... and beware of SQL attacks and injections!
    1 point
  5. So if it is inside a GUI you created, why on earth would you use mouse coordinates instead of the control functions? You say it is your GUI, so you should know the control IDs, and should be able to then click on or interact with any control without having to resort to using the mouse.
    1 point
  6. The problem is in the _ArrayDisplay function. When you use "" or Default, the default DataSeparatorChar is reset to "?" instead of "|". When the function ends, it resets it back to "|", but because you're using _ArrayDisplay inside the user function, it jumps out of the function before it's reset back, so the separator character is set to "?" and your _ArrayDisplay doesn't separate the column headers correctly. Even when you specify the separator character, the stringsplit function inside the _ArrayDisplay function is still using "?" as the separator.
    1 point
  7. You can also look at ControlGetFocus for a given window.
    1 point
  8. tarretarretarre, I use _WinAPI_GetFocus to do this. M23
    1 point
  9. http://daveyarwood.github.io/alda/2015/09/05/alda-a-manifesto-and-gentle-introduction/
    1 point
  10. In some ways it's not so surprising because we both base our syntax on an existing universal model - music notation. Yeah, I will do shortly. If you want to mention it straight away, by all means be my guest.
    1 point
×
×
  • Create New...