8 posts in this topic
Here's the beginnings of SFML (the Simple and Fast Multimedia Library) for AutoIT.
This library provides a wealth of features for developing games and multimedia applications. You can read up more about SFML here -> http://www.sfml-dev.org. It uses OpenGL as the renderer for 2D graphics such as sprites, so it's performance is quite good.
Currently my interest is in 2D sprite engines, so my focus is on the sprite and window APIs. This is the precursor to another separate UDF I'm working on and will release soon. If there's any interest I'll flesh out more of this API for the community.
CSFML is the "C" binding / API for SFML, and it's this API that I'm building this UDF against.
AutoIt3 3.2 or higher LIST OF FUNCTIONS (so far):
_CSFML_Startup _CSFML_Shutdown _CSFML_sfClock_create _CSFML_sfClock_getElapsedTime _CSFML_sfClock_restart _CSFML_sfVector2f_Constructor _CSFML_sfVector2f_Update _CSFML_sfVector2f_Move _CSFML_sfColor_Constructor _CSFML_sfColor_fromRGB _CSFML_sfSizeEvent_Constructor _CSFML_sfEvent_Constructor _CSFML_sfVideoMode_Constructor _CSFML_sfRenderWindow_create _CSFML_sfRenderWindow_setVerticalSyncEnabled _CSFML_sfRenderWindow_isOpen _CSFML_sfRenderWindow_pollEvent _CSFML_sfRenderWindow_clear _CSFML_sfRenderWindow_drawText _CSFML_sfRenderWindow_drawSprite _CSFML_sfRenderWindow_display _CSFML_sfRenderWindow_close _CSFML_sfTexture_createFromFile _CSFML_sfSprite_create _CSFML_sfSprite_destroy _CSFML_sfSprite_setTexture _CSFML_sfSprite_setPosition _CSFML_sfSprite_setRotation _CSFML_sfSprite_rotate _CSFML_sfSprite_setOrigin _CSFML_sfFont_createFromFile _CSFML_sfText_create _CSFML_sfText_setString _CSFML_sfText_setFont _CSFML_sfText_setCharacterSize _CSFML_sfText_setFillColor EXAMPLE:
Currently I only have one example, which is the "Short example" described in the CSFML API documentation, plus some extra features. Essentially a window (GUI) allowing you to move a sprite around with the keyboard (including rotation).
You can download this UDF, including the example and associated files, from the following GitHub page:
First off, yeah this may be the lamest title. But it made you look anyway!
Edit: Now updated! With step-counter, reset button and a few GUI-tweaks. (the step-counter is cheating! It's calculated in advance...)
I recently thought a screenshot of a finished maze may be smart to show, instead of only my long story and code. o=path, x=wall. Here it is:
I started making my own implementation of the A* pathing script in a larger project, inspired by Toady's work. (But made one from scratch myself anyway )
After the A* pathing script was working (not cleaned up yet) I wanted to test it. Unfortunately I got no good, randomized, maze lying around that also had the format I needed. So I made my own maze generator!
I did a few hours of research on the matter and then a few evenings of scripting.
For the people who are interested, one of my problems was that I needed 'one-cell' thick walls. Most maze generation have 1 pixel thick walls drawn by a line, that could be opened if a path is needed. The solution is so simple, I needed this guy to tell me. Click here for my inspiration source.
This generator can be used with different sizes maze, even uneven ones! Just set the width and height settings. FYI, it must be odd numbers for this maze to work with it's containment walls.
It's the 'simple' Depth-First Search, with backtracking. And without further ado; my a-maze-ing generator!:
#cs ---------------------------------------------------------------------------- AutoIt Version: 18.104.22.168 Author: A-maze-ing generator Script Function: Generates a maze. In the $xy[$i] is the maze in array form. Don't forget to take the size with it, else it's just a string of o's and x's It does not generate an entrance or exit! #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <Array.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> ; Set various variables ; width and height must be odd numbers to have a closed, functioning maze. Global $height = 27 ; demo height = 27 Global $width = 43; demo width = 43 ; Check if width & height are an odd number (to get the outer edge an odd number is required) If mod($height, 2) = 0 Or $height < 5 Then msgbox(0,"","Height is not an odd number or a minimum of 5 tall !") Exit ElseIf mod($width, 2) = 0 Or $width < 5 Then msgbox(0,"","Width is not an odd number of a minimum of 5 wide !") Exit EndIf ; Set various variables when script is not exited Global $grid_size = $height * $width Global $numberofsteps = (Ceiling(($height-2) / 2) * (($width-2) - Ceiling(($width-2) / 2))) + (($height-2) - Ceiling(($height-2) / 2)) ; long formula to check the number of steps this maze will take, this is a mathematical given with a fixed number of cells. And yes, I am aware I'm taking a shortcut in this formula. ;) Global $curpos Global $backtrack Global $bt = 0 Local $grid_pixel = 20 ;How many pixels per square ; Initialize main array with all grid data Global $xy[$grid_size + 1] Global $reset_xy = $xy ; set the reset array $xy = $grid_size ; first entry is the total number of nodes, rest is set with a header name for easy reference in _ArrayDisplay if needed. $xy = "ID" $xy = "Row" $xy = "Column" $xy = "Type" ; Fill the grid array with 'walls' For $i = 1 To $xy $xy[$i] = "x" Next ; Start GUI and create standard buttons Local $gui = GUICreate("A-maze-ing generator", 180 + ($width * $grid_pixel), 80 + ($height * $grid_pixel)) ; Set the main window to the minimum width (IF) needed for the msgbox Local $aPos = WinGetPos($gui) If $aPos < 696 Then $aPos = 696 WinMove($gui, "", $aPos, $aPos, $aPos, $aPos) EndIf GUICtrlCreateLabel("This is a-maze-ing!", 30, 19) Global $progress = GUICtrlCreateLabel("Standing by... " & $numberofsteps & " steps to go.", 150, 15, 550, 30) Local $iOKButton = GUICtrlCreateButton("Start", 45, 50, 60) Local $iResetButton = GUICtrlCreateButton("Reset", 45, 90, 60) Local $iExitButton = GUICtrlCreateButton("Exit", 45, 130, 60) GUICtrlSetFont($progress, 15) GUICtrlSetColor($progress, 0x00AA00) GUICtrlSetState($iResetButton, $GUI_DISABLE) ; Create label-grid and fill the xy array with the positions Local $squarenr = 0 For $i = 0 To ($height * $grid_pixel) - $grid_pixel Step $grid_pixel ; Row For $j = 0 To ($width * $grid_pixel) - $grid_pixel Step $grid_pixel ; Column $squarenr = $squarenr + 1 $xy[$squarenr] = GUICtrlCreateLabel('x', 150 + $j, 50 + $i, $grid_pixel, $grid_pixel, BitOr($SS_SUNKEN, $SS_CENTER)) ; if you want debugging numbers, replace 'x' with $squarenr GUICtrlSetBkColor($xy[$squarenr], 0x5E87C9) ; lightblue-ish $xy[$squarenr] = $squarenr $xy[$squarenr] = ($i / $grid_pixel) + 1 $xy[$squarenr] = ($j / $grid_pixel) + 1 Next Next $reset_xy = $xy ; Show GUI GUISwitch($gui) GUISetState(@SW_SHOW) ; Start looping and waiting for input Local $aMsg = 0 While 1 $aMsg = GUIGetMsg(1) Select Case $aMsg = $iOKButton GUICtrlSetState($iOKButton, $GUI_DISABLE) GUICtrlSetState($iResetButton, $GUI_DISABLE) GUICtrlSetState($iExitButton, $GUI_DISABLE) GUICtrlSetColor($progress, 0xFF8C00) ; orange GUICtrlSetData($progress, "Running - Creating maze. Please stand by... " & $numberofsteps & " steps to go.") make_maze() GUICtrlSetColor($progress, 0xFF0000) ; red GUICtrlSetData($progress, "Maze complete!") Sleep(1000) ; Just a small sleep for dramatic effect GUICtrlSetColor($progress, 0x00AA00) ; green-ish GUICtrlSetData($progress, "Maze completed in " & $numberofsteps & " steps.") GUICtrlSetState($iResetButton, $GUI_ENABLE) GUICtrlSetState($iExitButton, $GUI_ENABLE) Case $aMsg = $iResetButton GUICtrlSetData($progress, "Resetting maze...") reset_maze() GUICtrlSetState($iResetButton, $GUI_DISABLE) GUICtrlSetState($iOKButton, $GUI_ENABLE) GUICtrlSetData($progress, "Maze reset!") Sleep(1000) ; Just a small sleep for dramatic effect GUICtrlSetData($progress, "Standing by...") Case $aMsg = $GUI_EVENT_CLOSE Or $aMsg = $iExitButton ExitLoop EndSelect WEnd Exit ; Resetting the maze to default state Func reset_maze() $xy = $reset_xy ; Set the $xy array back to it first-run values For $i = 1 To $xy $xy[$i] = "x" ; set everything to 'x' GUICtrlSetBkColor($xy[$i], 0x5E87C9) ; reset the background color GUICtrlSetData($xy[$i], "x") ; (re)set the label to 'x' Next EndFunc ; Main function Func make_maze() Local $heading Local $stepcount = $numberofsteps ; Reset the step counter. Local $timed = TimerInit() ; Start the timer to see how long the maze generation took. $backtrack = 0 $curpos = $width + 2 ; This is the starting position, second row, second column - aka top-left, one in from the sides. open_maze($curpos) ; Set the starter cell to 'open / white' ; Main maze generation loop While 1 Do $heading = direction($curpos) Until $heading <> 0 If $bt = 1 Then $bt = 0 ; reset backtracking-tracker, else the backtracking array keeps adding the current position GUICtrlSetData($progress, "Running - Creating maze. Please stand by... " & $stepcount & " steps to go.") Sleep(50) ; Slow maze creation down to look at it - relax! (or don't and comment out the sleep) If $heading = -1 Then ExitLoop $stepcount -= 1 ; Count down the steps to finish. ; We got the heading - now which way do we go? After that, set the current position to the last known heading. Switch $heading Case 1 ; north open_maze($curpos - $width) open_maze($curpos - ($width * 2)) $curpos = $curpos - ($width * 2) Case 2 ; east open_maze($curpos + 1) open_maze($curpos + 2) $curpos = $curpos + 2 Case 3 ; south open_maze($curpos + $width) open_maze($curpos + ($width * 2)) $curpos = $curpos + ($width * 2) Case 4 ; west open_maze($curpos - 1) open_maze($curpos - 2) $curpos = $curpos - 2 EndSwitch ;msgbox(0,"","Turn pause") ; for debugging, click every turn. WEnd ConsoleWrite("Maze completed in " & Round(TimerDiff($timed) / 1000, 1) & " seconds." & @CRLF) ; Show the generation time in seconds, rounded up with one decimal Return EndFunc Func open_maze($dest) ; Function set inputted cells to 'open' instead of being an uncool wall. $xy[$dest] = "o" GUICtrlSetData($xy[$dest], 'o') ; If you want debugging numbers, replace 'o' with $dest GUICtrlSetBkColor($xy[$dest], 0xEEEEEE) EndFunc Func direction(ByRef $curpos) ; Insert current position, output next heading for path generation. Local $nesw Local $open_directions $open_directions = 0 $nesw = $curpos - ($width * 2) ; north side checking If $nesw > $width + 1 Then fill_open_dir($nesw, 1, $open_directions) $nesw = $curpos + 2 ; east side checking If mod($nesw - 1, $width) <> 0 Then fill_open_dir($nesw, 2, $open_directions) $nesw = $curpos + ($width * 2) ; south side checking If $nesw < $grid_size - $width Then fill_open_dir($nesw, 3, $open_directions) $nesw = $curpos - 2 ; west side checking If mod($nesw, $width) <> 0 Then fill_open_dir($nesw, 4, $open_directions) ; Check which (if any) direction(s) are already opened, if so, discard them from the results-array For $i = $open_directions To 1 Step -1 If $xy[$open_directions[$i]] = "o" Then $open_directions -= 1 _ArrayDelete($open_directions, $i) EndIf Next ; If there are any results left... If $open_directions > 0 Then If $open_directions = 1 Then Return $open_directions ; Random does not work with min 1 and max 1 (output = 0), so in this case, return only with the only one result. Else If $bt = 0 Then ; If there is not backtracking active, add this crossroad to the backtrack-array. This is only needed if there are two or three possible sides. $backtrack += 1 _ArrayAdd($backtrack, $curpos) EndIf Return $open_directions[Random(1, $open_directions, 1)] ; Random choose between all possible directions and return with the outcome direction. EndIf ElseIf $backtrack > 0 Then ; If there are no results ánd there are entries in the backtrack list, then visit those entries to see if there still is a path possible. $curpos = $backtrack[$backtrack] _ArrayDelete($backtrack, $backtrack) $backtrack -= 1 $bt = 1 Return 0 ; Return with a new current direction ($curpos), from the backtrack array. Else Return -1 ; If there are no paths to explorer, in the pathing, or backtracking, then return with the message that we are finished. EndIf EndFunc Func fill_open_dir($nesw, $direction, ByRef $open_directions) ; Fill the $open_directions array with a new possible way $open_directions += 1 $open_directions[$open_directions] = $nesw $open_directions[$open_directions] = $direction Return EndFunc
P.S. The 'slow' generation is intended because it looks cool. Comment out the Sleep line on line 157 for a fast generation.
Hey guys! I need to find a way to wrap an autoit gui around a game. I am planning on making a custom gui overlay for interacting with my stream, which will allow me to run giveaways and stuff like that. But I need to find a way to force the steam games to run inside my autoit gui... I have the following code so far credit to those I took code from and modified to suite my needs "can't remember who u are pls post if i owe ty to u" If I select notepad and launch it then it works great! and the notepad window is wrapped inside my gui. However if I try it with teamfortress 2 it won't work...
#include <Array.au3> #include <File.au3> #include <WinAPI.au3> #include <GUIConstants.au3> Local $msg, $hwnd, $WinHwnd ;===> UDV Start $pid = 0 $Hidden = 0 $exe = 0 $sDrive = 0 $sDir = 0 $sFileName = 0 $sExtension = 0 ;===> UDV End $hwnd = GUICreate("hello") $Open = GUICtrlCreateButton("Launch Game", 10, 30, 75, 25) $Select = GUICtrlCreateButton("Select Game", 10,60,75,25) GUISetState() ;===> UDF START Func _GetWinHwnd($pid) $aWinlist = WinList() For $i = 1 To $aWinlist If $pid = WinGetProcess($aWinlist[$i]) Then Return $aWinlist[$i] Next EndFunc ;==>_GetWinHwnd Func _SetParentWindow($pid) $WinInfo = _GetWinHwnd($pid) $WinHwnd = ControlGetHandle($WinInfo, "", "") _WinAPI_SetParent($WinHwnd, $hwnd) _WinAPI_SetWindowLong($WinHwnd, $GWL_STYLE, $WS_POPUP + $WS_VISIBLE) WinMove($WinHwnd, "", 0, 0) EndFunc ;==>_SetParentWindow Func RedrawGui($RedrawMe) If ProcessExists($pid) And $Hidden = 0 Then GUICtrlSetState($RedrawMe, @SW_HIDE) $Hidden = 1 sleep(50) _WinAPI_RedrawWindow($pid) Sleep(50) ElseIf $Hidden = 1 And Not ProcessExists($pid) Then GUICtrlSetState($RedrawMe, @SW_SHOW) $Hidden = 0 EndIf EndFunc ;===> UDF END While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE If ProcessExists($pid) Then ProcessClose($pid) GUICtrlSetState($Open, @SW_SHOW) Else Exit EndIf Case $Open GUICtrlSetState($Open, @SW_HIDE) Sleep(100) $pid = Run('"' & $exe & '" -game tf -steam') #cs This RUN CMD is custom made for testing with TF2 change to just $exe to select any exe you want to test with -game tf specifies to launch tf2 and -steam gets rid of insecure mode error #ce RedrawGui($Open) ProcessWait($pid) Sleep(5500) _GetWinHwnd($pid) _SetParentWindow($pid) Case $Select $exe = FileOpenDialog("Please select your game!", @ScriptDir, "Executable File (*.exe)", "1", "Process Selection") Sleep(50) FileChangeDir(@ScriptDir) _PathSplit($exe, $sDrive, $sDir, $sFileName, $sExtension) EndSwitch WEnd
I don't know if it is possible but I am creating a little program to catalog my game collection.
It would be awesome if my program could get the boxcover, developer info and game info with the titles I add.
Does anyone know how to get me started?
Here my 1st game ever.
A try to remake of the arcade classical 2D game Asteroids® by Atari (1979).
More information about Asteroids® here or here!
Play online here
Please don't link to file below directly from other websites!
Downloads (2263 previously): AUTOITEROIDS v1.019 Build 2016-01-14.7z (use e.g. 7-Zip to extract archive)
Only compiled version incl. needed files here: <4shared.com> or <MediaFire.com>
This game is an unoffical clone of the original Asteroids®
game and is not endorsed by the registered trademark
and copyright owners Atari Interactive, Inc.
AUTOITEROIDS is a remake of the video arcade game released in 1979 by Atari, Inc.
It was one of the most popular and influential games of the Golden Age of Arcade Games.
The player controls a spaceship in an asteroid field which is periodically traversed by flying saucers.
The object of the game is to shoot and destroy asteroids and saucers while not colliding with either,
or being hit by the saucers' counter-fire.
ctrl - shoot,
up - thrust,
left - turn left,
right - turn right,
space - hyper jump
game is starting with 3 asteroids
every 10.000 points increase of level (among other things amount of asteroids + 1)
every 30.000 points extra live
biggest asteroid = 20 points
medium asteroid = 50 points
smallest asteroid = 100 points
big alien spaceship = 200 points
small alien spaceship = 1000 point
Main code: UEZ
Bass UDF: BrettF
Bass DLL: www.un4seen.com
GDI+ font loader code: Yashied
Menu item code: rasim
Sound + sound code modifications: Spiff59
Font: ck! [Freaky Fonts]
GetKeyboardState code: eukalyptus
Atari for the original game concept
AutoIt forum for all the help and the source of knowledge