Jump to content

All Activity

This stream auto-updates

  1. Past hour
  2. We had few zoom meetings witch give us a new look on each other.
  3. Today
  4. ..just a note to tell you that you are now in my ignore list.
  5. Sorry to bring up this little off-topic part, but: @mLipok and @Jos your conversation about getting older and starting to forget things made my morning (7 o'clock AM in germany) - very funny to be honest and nice to read you both know each other for years (at least in the forum). I like that πŸ˜€ . Sorry to hear/read that MichaΕ‚ πŸ˜” . I hope you will now constantly been out of this and don't get stressed out again πŸ€ ! Best regards, especially to you both but also to all others who read along, Sven
  6. AdlibRegister("Clock", 1000) HotKeySet("{esc}", "exit1") $seconds = 3600 GUICreate("Timer", 181, 50) GUISetBkColor(0x000000) GUICtrlCreateLabel("00:00:00", 10, 0, 200, 70) GUICtrlSetFont ( -1, 30, 800 ) GUICtrlSetBkColor(-1, 0x000000) GUICtrlSetColor(-1, 0xFFFFFF) GUISetState (@SW_SHOW) While True $minutes = Mod($seconds/60, 60) $hours = $seconds/3600 $display = StringFormat("%02i:%02i:%02i", $hours, $minutes, Mod($seconds, 60)) WinSetOnTop("Time", "", 1) WEnd Func clock() If $seconds > 0 Then $seconds -= 1 EndIf GUICtrlSetData(-1, $display) EndFunc Func exit1() exit EndFunc
  7. I understand you and believe me I don't want to have problems with anyone on this site. I am Mexican so I don't know much English and I use translator. If I said something bad about Joe I apologize. I am a good and respectful person.
  8. AdlibRegister("Reloj", 1000) HotKeySet("{esc}", "salida1") $segundos = 3600 GUICreate("Temporizador", 181, 50) GUISetBkColor(0x000000) GUICtrlCreateLabel("00:00:00", 10, 0, 200, 70) GUICtrlSetFont ( -1, 30, 800 ) GUICtrlSetBkColor(-1, 0x000000) GUICtrlSetColor( -1, 0xFFFFFF) GUISetState (@SW_SHOW) Mientras que True $minutos = Mod($segundos/60, 60) $horas = $segundos/3600 $display = StringFormat("%02i:%02i:%02i", $horas, $minutos, Mod($segundos, 60) ) WinSetOnTop("Hora", "", 1) WEnd Func reloj() Si $segundos > 0 Entonces $segundos -= 1 EndIf GUICtrlSetData(-1, $display) EndFunc Func exit1() salir EndFunc
  9. ....and don't get me in trouble. The one chatting with you is well respected by me and a moderator in this site. And I didn't like your typo in regards to the name. And don't say "my English", I've read every post you made.
  10. I don't see that include. Nor any code. Don't upload the script as I will not download it. When posting code, do it in a code box. Make sure is running code and not just chucks.
  11. thanks argumentum for replying. what I am looking for is how to save the time as soon as I close it Chronometer.au3 example: time -05:35 and I close it .au3. when I open the .au3 again it will continue in the time -05:34.
  12. Hello Jose, I apologize for the misunderstandings. I'm just learning to program with autoit. If the problem is that you don't want me to post about the stopwatch? I understand you. but in this case I just want to learn how to program with autoit. I don't know what the problem is that you have with me and I would like to solve it? I've already apologized to you, about my question, I just want you to save the elapsed time and then continue where you left off. I am just asking for help on how to do it or where to look for it or examples that can help me. just that sorry for my bad English, I hope you understand me.
  13. The output comes out as weird characters like a symbol as shown in the attached image. I'm trying to get the whole page content (source) and then parse the data I need. I'm just wondering if you know a way to get the source code for that page again. I'd do it the _IECreate /w _IEDocReadHTML method but that makes my tool run slower because it technically has to open a hidden browser and then take the source code from that and then close that hidden browser, but if there's no solution to the _InetGetSource way then i'll do it.
  14. Yesterday
  15. The script doesn't run since you use some unknown script called Print.au3 (at least in the latest AutoIt version). If you comment the line then the script run but the collision doesn't seems to work. Also the flicker is present even when the length of the snake it's just one and get worse when the length increase. Mabye drawing the objects using GDI+ will fix this issue. Overall it's a good start but it leaves room for improvements.
  16. Sometimes, the most interesting discoveries happen by accident. That's how I stumbled upon an old post presenting a classic version of the game Snake. However, rather than simply appreciating the game as it was, I saw an opportunity for improvement by using AutoItObject.au3 , a powerful tool that didn't exist at the time of the original version's creation. In this article, I'll introduce you to my object-oriented version of Snake Game, which brings flexibility and modernity to this timeless classic. AutoItObject.au3 is an incredibly flexible tool that allows for modular and efficient application and game development. With this library, I was able to completely rethink the structure of the Snake game, transforming it into a rich and dynamic object-oriented experience. This means that every entity in the game, from the snake to the food to the user interface, is represented as a distinct object, offering extraordinary flexibility and extensibility. One of the main features of my version of Snake Game is the ability for players to express their own preferences and customize the gaming experience to their liking. Whether adjusting the score, modifying the difficulty level, or adding new game elements, players have the freedom to shape the game to suit their preferences. Despite its underlying complexity, using AutoItObject.au3 makes the code for Snake Game surprisingly simple and easy to understand. Each game object is carefully encapsulated and modeled to accurately reflect its behavior in the real world. This means that developers can easily add new features or modify the game without compromising its stability or quality. By reimagining Snake Game through the lens of object-oriented programming with AutoItObject.au3, I was able to create a version of the game that combines the simplicity of the original classic with the flexibility and modernity of object-oriented programming. I look forward to seeing how this version evolves over time, and I hope it inspires other developers to rethink their own projects using this powerful library. #include-once #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 ; #INDEX# ======================================================================================================================= ; Title .........: Snake Game ; AutoIt Version : 3.3 ; AutoItObject Version : v1.2.8.2 ; Language ......: English ; Description ...: A simple Snake game implementation using AutoIt->AutoItObject.au3. ; Dependencies ..: AutoItObject.au3 ; Author ........: Numeric ; =============================================================================================================================== #include <GUIConstantsEx.au3> #include "AutoItObject.au3" #include <Print.au3> #include <Misc.au3> Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") _AutoItObject_Startup() Func Snake($oPoint = 0, $Board = Default) Local $aRandomDirectionTab = [-1, 0, 1] Local $dx = $aRandomDirectionTab[Int(Random(0, 2, 1))] Local $dy = $aRandomDirectionTab[Int(Random(0, 2, 1))] Local $iLowSpeed = 100 Local $foodCounter = 0 If $Board = Default Then $Board = GUICreate("Snake", 400, 400) GUISetBkColor(0x000000) GUISetState() Local $aBoardPos = WinGetClientSize($Board) If @error Then Return SetError(1, 0, False) ; window not found Local $iBoardWidth = $aBoardPos[0] Local $iBoardHeight = $aBoardPos[1] Local $X = Random(10, $iBoardWidth - 10, 1) Local $Y = Random(10, $iBoardHeight - 10, 1) If $oPoint = 0 Then $oPoint = Point($X, $Y) Local $aMap[] MapAppend($aMap, $oPoint) Local $oFood = Point(Random(10, $iBoardWidth - 10), Random(10, $iBoardHeight - 10), 39219) Local $sClass = _AutoItObject_Class() With $sClass .Create() .AddProperty("head", $ELSCOPE_PRIVATE, $oPoint) .AddProperty("aMap", $ELSCOPE_PRIVATE, $aMap) .AddProperty("food", $ELSCOPE_PRIVATE, $oFood) .AddProperty("foodCounter", $ELSCOPE_PRIVATE, $foodCounter) .AddProperty("dx", $ELSCOPE_PRIVATE, $dx) .AddProperty("dy", $ELSCOPE_PRIVATE, $dy) .AddProperty("Board", $ELSCOPE_PRIVATE, $Board) .AddProperty("speedLevel", $ELSCOPE_PRIVATE, $iLowSpeed) .AddProperty("iBoardWidth", $ELSCOPE_PRIVATE, $iBoardWidth) .AddProperty("iBoardHeight", $ELSCOPE_PRIVATE, $iBoardHeight) .AddMethod("getBoard", "_getBoard") .AddMethod("setSpeedLevel", "_setSpeedLevel") .AddMethod("getSpeedLevel", "_getSpeedLevel") .AddMethod("runGameLoop", "_runGameLoop") .AddMethod("setdx", "_setdx") .AddMethod("setdy", "_setdy") .AddMethod("getdx", "_getdx") .AddMethod("getdy", "_getdy") .AddMethod("sleepW", "_sleepW") .AddMethod("getMap", "_getMap") .AddMethod("setMap", "_setMap") .AddMethod("getHead", "_getHead") .AddMethod("getBoardHeight", "_getBoardHeight") .AddMethod("getBoardWidth", "_getBoardWidth") .AddMethod("getFoodCounter", "_getFoodCounter") .AddMethod("setFoodCounter", "_setFoodCounter", True) .AddMethod("move", "_move", True) .AddMethod("generateFood", "_generateFood") .AddMethod("setFood", "_setFood") .AddMethod("getFood", "_getFood") .AddDestructor("_destructor") EndWith Return $sClass.Object EndFunc ;==>Snake Func _destructor($this) ConsoleWrite("Destructor ....." & @CRLF) Local $aMap = $this.getMap() For $oPoint In $aMap $oPoint = 0 Next $aMap = 0 $this.setMap(0) EndFunc ;==>_destructor Func _getFoodCounter($this) Return $this.foodCounter EndFunc ;==>_getFoodCounter Func _setFoodCounter($this, $foodCounter) $this.foodCounter = $foodCounter EndFunc ;==>_setFoodCounter Func _setSpeedLevel($this, $iLevel) $this.speedLevel = $iLevel EndFunc ;==>_setSpeedLevel Func _getSpeedLevel($this) Return $this.speedLevel EndFunc ;==>_getSpeedLevel Func _getBoard($this) Return $this.Board EndFunc ;==>_getBoard Func _runGameLoop($this) While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop If _IsPressed(25) Then $this.setdx(-1) $this.setdy(0) EndIf If _IsPressed(27) Then $this.setdx(1) $this.setdy(0) EndIf If _IsPressed(26) Then $this.setdx(0) $this.setdy(-1) EndIf If _IsPressed(28) Then $this.setdx(0) $this.setdy(1) EndIf If _IsPressed(53) Then $this.sleepW() EndIf $this.move() Sleep($this.getSpeedLevel()) WEnd EndFunc ;==>_runGameLoop Func _getBoardWidth($this) Return $this.iBoardWidth EndFunc ;==>_getBoardWidth Func _getBoardHeight($this) Return $this.iBoardHeight EndFunc ;==>_getBoardHeight Func _generateFood($this) Local $oFood = Point(Random(10, $this.getBoardWidth() - 10), Random(10, $this.getBoardHeight() - 10), 39219) $this.setFood($oFood) EndFunc ;==>_generateFood Func _setFood($this, $oFood) $this.food = $oFood EndFunc ;==>_setFood Func _getFood($this) Return $this.food EndFunc ;==>_getFood Func _getHead($this) Return $this.head EndFunc ;==>_getHead Func _setdx($this, $dx) $this.dx = $dx EndFunc ;==>_setdx Func _setdy($this, $dy) $this.dy = $dy EndFunc ;==>_setdy Func _getdx($this) Return $this.dx EndFunc ;==>_getdx Func _getdy($this) Return $this.dy EndFunc ;==>_getdy Func _getMap($this) Return $this.aMap EndFunc ;==>_getMap Func _setMap($this, $aMap) $this.aMap = $aMap EndFunc ;==>_setMap Func _move($this) Local $aMap = $this.getMap() Local $head = $aMap[0] Local $newX = $head.getXPos() + $this.getdx() * 10 Local $newY = $head.getYPos() + $this.getdy() * 10 ; Vérifier si la tête du serpent sort de l'écran If $newX <= 0 Or $newX >= $this.getBoardWidth() - 10 Or $newY <= 0 Or $newY >= $this.getBoardHeight() - 10 Then Return SetError(1, 0, False) EndIf Local $oFood = $this.getFood() If $head.checkCollision($oFood) Then $this.setFoodCounter($this.getFoodCounter() + 1) Local $lastSegment = $aMap[UBound($aMap) - 1] Local $lastX = $lastSegment.getXPos() + $this.getdx() * 10 Local $lastY = $lastSegment.getYPos() + $this.getdy() * 10 MapAppend($aMap, Point($lastX, $lastY)) $this.setMap($aMap) If $this.getFoodCounter() = 4 Then Local $newSpeedLevel = $this.getSpeedLevel() - 20 If $newSpeedLevel < 0 Then $newSpeedLevel = 1 $this.setSpeedLevel($newSpeedLevel) $this.setFoodCounter(0) EndIf GUICtrlDelete($oFood.getID()) $this.generateFood() EndIf ; Mettre à jour la position de la tête du serpent $head.setXPos($newX) $head.setYPos($newY) ; Déplacer les segments du serpent For $i = UBound($aMap) - 1 To 1 Step -1 $aMap[$i].setXPos($aMap[$i - 1].getXPos()) $aMap[$i].setYPos($aMap[$i - 1].getYPos()) Next EndFunc ;==>_move ;bug Func _sleepW(ByRef $this) Do Do Sleep(100) Until _IsPressed(25) Or _IsPressed(26) Or _IsPressed(27) Or _IsPressed(28) If _IsPressed(25) Then $this.setdx(-1) $this.setdy(0) EndIf If _IsPressed(27) Then $this.setdx(1) $this.setdy(0) EndIf If _IsPressed(26) Then $this.setdx(0) $this.setdy(-1) EndIf If _IsPressed(28) Then $this.setdx(0) $this.setdy(1) EndIf Until _IsPressed(25) Or _IsPressed(26) Or _IsPressed(27) Or _IsPressed(28) EndFunc ;==>_sleepW Func Point($X = 0, $Y = 0, $iClolor = 16777215) Local $idLabel = GUICtrlCreateLabel("", $X, $Y, 10, 10, 0x0001) ; $BS_CENTER GUICtrlSetBkColor($idLabel, $iClolor) Local $cPoint = _AutoItObject_Class() With $cPoint .Create() .AddProperty("___sType___", $ELSCOPE_PRIVATE, "Point") .AddProperty("X", $ELSCOPE_PRIVATE, $X) .AddProperty("Y", $ELSCOPE_PRIVATE, $Y) .AddProperty("iColor", $ELSCOPE_PRIVATE, $iClolor) .AddProperty("idLabel", $ELSCOPE_PRIVATE, $idLabel) .AddMethod("getObjType", "_getObjType") .AddMethod("setXPos", "_setXPos") .AddMethod("setYPos", "_setYPos") .AddMethod("getID", "_getID") .AddMethod("setID", "_setID") .AddMethod("getXPos", "_getXPos") .AddMethod("getYPos", "_getYPos") .AddMethod("checkCollision", "_checkCollision") EndWith Return $cPoint.Object EndFunc ;==>Point Func _getObjType($this) Return $this.___sType___ EndFunc ;==>_getObjType Func _checkCollision($this, $oPoint) If Not IsObj($oPoint) Then Return SetError(1, 0, False) Local $sType = $oPoint.getObjType() If $sType <> "Point" Then Return SetError(2, 0, False) Local $aPos1 = ControlGetPos("", "", $this.getID()) Local $aPos2 = ControlGetPos("", "", $oPoint.getID()) If $aPos1[0] + $aPos1[2] >= $aPos2[0] And $aPos1[0] <= $aPos2[0] + $aPos2[2] And $aPos1[1] + $aPos1[3] >= $aPos2[1] And $aPos1[1] <= $aPos2[1] + $aPos2[3] Then Return True EndIf Return False EndFunc ;==>_checkCollision Func _setXPos($this, $iX) $this.X = $iX GUICtrlSetPos($this.idLabel, $iX, $this.getYPos()) EndFunc ;==>_setXPos Func _setYPos($this, $iY) $this.Y = $iY GUICtrlSetPos($this.idLabel, $this.getXPos(), $iY) EndFunc ;==>_setYPos Func _getXPos($this) Return $this.X EndFunc ;==>_getXPos Func _getYPos($this) Return $this.Y EndFunc ;==>_getYPos Func _getID($this) Return $this.idLabel EndFunc ;==>_getID Func _setID($this, $idLabel) $this.idLabel = $idLabel EndFunc ;==>_setID ;*************************************************** Global $sNake = Snake() $sNake.runGameLoop() $sNake = 0 ;************************************************** _AutoItObject_Shutdown()
  17. btw. Used several times today. It worked like a charm.
  18. There was a time when I had major depression combined with professional burnout. I'm getting over it. In the meantime, I didn't feel like programming, so I might have forgotten some things
  19. This is what we call decompiling and there are strict forum rules around that! *click*
  20. You are getting old my friend and start forgetting things
  21. I inherited a bunch of AutoIT scripts from a previous engineer and majority of them are in a code repository so I have access to the source code. There are a couple however that I aren't in the repo that I need to get the source code for. My issue is that they are .a3x files and are encoded. How would I go about decoding these files so I can get the source code?
  22. That's more like it. now I get... Eagle 1785 Face 1690
  23. I changed it to 2 decimals, too. Now more colors will be used.
  24. Earlier i adjusted this part... Select Case fGreys Case 0.05 To 0.18 iB = 1 Case 0.19 To 0.34 iG = 1 Case 0.35 To 0.50 iB = 1 iG = 1 Case 0.51 To 0.66 iR = 1 Case 0.67 To 0.82 iR = 1 iB = 1 Case 0.83 To 0.95 iR = 1 iG = 1 End Select ..to use only 2 decimal places, if the decimal places are longer than 2 it misses some going from case to case, scroll up and see the changes.
  25. Here the function in FB: Function _GDIPlus_BitmapCreateFakeGreyscale(hImage As Any Ptr, bGDI As BOOL = False) As Any Ptr Export Dim As Single iW, iH Dim As Double fGreys, fLuma Dim As Any Ptr hBitmap_Greyscale, hGDIBitmap Dim As BitmapData tBitmapData, tBitmapData_Greyscale Dim As Long iX, iY, iRowOffset, iColor, c, iR, iG, iB GdipGetImageDimension(hImage, @iW, @iH) Dim As RECT tRect = Type(0, 0, iW - 1, iH - 1) GdipCreateBitmapFromScan0(iW, iH, 0, PixelFormat32bppARGB, 0, @hBitmap_Greyscale) GdipBitmapLockBits(hBitmap_Greyscale, Cast(Any Ptr, @tRect), ImageLockModeWrite, PixelFormat32bppARGB, @tBitmapData_Greyscale) GdipBitmapLockBits(hImage, Cast(Any Ptr, @tRect), ImageLockModeRead, PixelFormat32bppARGB, @tBitmapData) For iY = 0 To iH - 1 iRowOffset = iY * iW For iX = 0 To iW - 1 iColor = Cast(ULong Ptr, tBitmapData.Scan0)[iRowOffset + iX] iR = (iColor Shr 16) And &hFF iG = (iColor Shr 8) And &hFF iB = iColor And &hFF fLuma = (iR * 213 + iG * 715 + iB * 72) / 1000 'fLuma = ((iR * 0.3) + (iG * 0.59) + (iB * 0.11) / 3) fGreys = fLuma - CUByte(fLuma) fLuma = CUByte(fLuma) iR = 0 iG = 0 iB = 0 Select Case fGreys Case 0.05 To 0.18 iB = 1 Case 0.19 To 0.34 iG = 1 Case 0.35 To 0.50 iB = 1 iG = 1 Case 0.51 To 0.66 iR = 1 Case 0.67 To 0.82 iR = 1 iB = 1 Case 0.83 To 0.95 iR = 1 iG = 1 End Select Cast(ULong Ptr, tBitmapData_Greyscale.Scan0)[iRowOffset + iX] = &hFF000000 Or ((fLuma + iR) Shl 16) Or ((fLuma + iG) Shl 8) Or (fLuma + iB) Shl 0 Next Next GdipBitmapUnlockBits(hBitmap_Greyscale, @tBitmapData_Greyscale) GdipBitmapUnlockBits(hImage, @tBitmapData) If bGDI Then GdipCreateHBITMAPFromBitmap(hBitmap_Greyscale, @hGDIBitmap, &hFF000000) GdipDisposeImage(hBitmap_Greyscale) Return hGDIBitmap EndIf Return hBitmap_Greyscale End Function I will play around with different values...
  26. Nice, how does the code look in freebasic, not that I'm gonna start with freebasic, just curious. I noticed we dont get same results, I take it you didnt use LUMA but the " (iR * 213 + iG * 715 + iB * 72) / 1000" you mentioned, quite a difference, i get... Eagle.jpg: yours 1020 grays, mine 1654 Face, png: yours 978, mine 1576 Maybe a switch parameter where the user can select between "Average", "LUMA", "Yours" and whatever other there might be.
  1. Load more activity
×
×
  • Create New...