Leaderboard
Popular Content
Showing content with the highest reputation on 09/19/2015 in all areas
-
1 point
-
_GDIPlus collision
TheDcoder reacted to TheNorwegianUser for a topic
Well, thanks for all the help! I've gotten a lot further, and this is my progress so far. For pictures to be displayed in the buttons simply press the prnt scrn button while playing a level. Any further suggestion of any sort would be appreciated #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 EndFunc1 point -
CodeWars
guinness reacted to jvanegmond for a topic
I'm doing the C# ones too. I have seen some of the ugliest verbose hacks in other people their work (some guy named Jon?) and here I am writing best practices code without pause, putting forth my best behavior. I have become boring! Please send help! Edit Me and guinness are allies. Go team AutoIt!1 point -
sent Msg With TCP Socket
07Coder reacted to SkythekidRS for a topic
#SERVER #SERVER TCPStartup() $data=InputBox('INPUT','TEXT') $main=TCPListen(@IPAddress1,4444,100) Do $socket=TCPAccept($main) Until $socket<>-1 TCPSend($socket,'--msg' & $data) TCPCloseSocket($socket) TCPShutdown() #CLIENT TCPStartup() $main=TCPConnect(@IPAddress1,4444) Do $data=TCPRecv($main,255) Until StringInStr($data,'--msg') $data=StringReplace($data,'--msg','') MsgBox(0,'',$data) TCPShutdown() I HOPE THIS WILL HELP YOU :D1 point -
CodeWars
jvanegmond reacted to Jon for a topic
Hahahah - just did all the if statements for checking if something was a leap year only to see the final top-rated solution: return DateTime.IsLeapYear(year);1 point -
1 point
-
Look in the help file for TCPRecv, the example script should get you started.1 point
-
Tools Recommendation for making CHM files
jvanegmond reacted to TheDcoder for a topic
Ok, so here is my new setup: 1. CKEditor with many plugins in local XAMPP installation for generating html 2. KEL CHM Editor for CHM Managment 3. HTML Help Workshop for compiling CHM files TD1 point -
Taking the sqare root of -1 ( i ) is only an error when the operation takes place outside of the suitable set within a given math "theory" (a set of axioms), for instance the set of so-called complex numbers, namely ℂ. As you say, everything is context-dependant. Yet there are rules that needs to be observed in every math context, like predicate logic, because they are the funding of the mathematical thinking. If you create new fundamental rules (i.e. a new axiomatic), then you're building another distinct math construct (theory) with which you're left alone. When doing mathematical operations with a computer, things are a little more fuzzy, because you're always limited by implementation possibilities. That may be by limited integer or real (FP) representation, by the difficulty to implement abstract entities or by the time operations require. As a basic example of such difficulty, there is no good way to perform actual computations with the real counterpart of the rational ⅓ which is normaly noted 0.3 with a black dot above the 3. Even an unlimited precision arithmetic library can't represent it (it can represent unbounded precision but not infinite precision). So an error in computer context is nothing more than hitting one limitation of the hardware or software you use even if you stay within a sound mathematical theory (don't violate the set of rules of the underlying axiomatic).1 point
-
i can't help but recall that _FileListToArray() returns an error when no files found - which is a perfectly valid result. i'd presume error definition varies quite widely, in any discipline you look at. in general, i would say that an error should be defined as a situation which prevented you (or your script, or your mathematical operator) from performing its task. as far as math is concerned, being the most abstract of all exact sciences, i'd recon one would have to work pretty hard to formulate such circumstances, if possible at all. for your example, -1^0.5, although hardly useful, may well be a perfectly valid result, in some unforeseen scenario. let's look at the other approach: say i currently cannot imagine such a scenario, therefore i define it as an error - that would be quite arrogant on my part; and when such scenario does come to existence, would i say "oh, the error was resolved."? ridiculous. and as for programming - one should sanitize input before processing, so if an error does occur, it is most likely a "real" error, not just feeding gibberish to functions.1 point
-
1 point
-
its archived since 2010 so do not expect support on it. Alternatives are completely depending on what you want to achieve. many datadriven and keyword automation frameworks are flowing around ie.udf, ff.udf, chrome.udf in the examples forum native autoit commands can do a lot on windows controls TN3270 / mainframe https://www.autoitscript.com/forum/topic/177156-trying-to-read-the-data-in-mainframe-screen-but-not-able-to/1 point
-
1 point
-
MetroGUI UDF v5.1 - Windows 10 style buttons, toggles, radios, menu etc.
coffeeturtle reacted to BBs19 for a topic
http://sourceforge.net/projects/tvshowcountdown/1 point -
So, you want to read your CMOS. There are two ways. Use driver or use VDM - this time I'm not wrong. porttalk.sys is one of the drivers written for those purposes (and more). In attached zip there are both AutoIt script to control the driver and a driver itself. Information about that driver can be found at beyondlogic <- that's a link, follow it. So, the script is demonstrating installing driver with all necessary steps to make it working, controlling the driver, shutting it down and deinstalling it. Also while the driver is functional I will use it to read the whole CMOS. And will also extract time data out of it. The way I'm reading I could also write to CMOS. I'm not doing that and not posting it either, for obvious reasons. PORTTALK -AutoIt CMOS.zip All you have to do is extract folder out of that zip and run DriverScript.au3.1 point
-
Where is the Scite forum?
andrew2344441 reacted to therks for a topic
Yay. I love it when I can help someone. It makes me feel all warm and gooey inside. Like a marshmallow... except I don't like marshmallows, so more like something warm and gooey that I like, I just can't think of anything right now.1 point