UEZ

[GAME] AUTOITEROIDS v1.019 Build 2016-01-14 Final

55 posts in this topic

#1 ·  Posted (edited)

Here my 1st game ever.

 

A try to remake of the arcade classical 2D game Asteroids® by Atari (1979). :D

 

More information about Asteroids® here or here!

 

Play online here :idea:

 

 

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>

 

 

post-29844-1242504010_thumb.png

 

 

 

LEGAL NOTICE:

 

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.

 

 

 

Short description:

 

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.

 

 

Keys:

 

ctrl - shoot,

up - thrust,

left - turn left,

right - turn right,

space - hyper jump

 

 

Game details:

 

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

 

 

Credits:

 

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 :P

 

Have fun :party:

UEZ

:D

 

 

Change log:

2009-05-16 release of the game AUTOITEROIDS

2009-05-17 thanks to Spiff59 for modification of the sound part -> now the sound is much smoother

2009-05-18 adjusted collision parameters -> now much better collision detection

2009-05-24 added highscore feature and fixed several bugs (RC1)

2009-05-31 pre final version released (only credit intro left)

2009-06-09 some bugs fixed and made some game setting modifications -> game play now smoother; also collision detection adjusted again; credit intro still in building phase :-(

2009-06-11 fixed some wrong game settings and change highscore file format -> now encrypted to avoid highscore manipulation ;-). Old score will be overwritten!

2009-06-13 display of level in GUI title menu was not working properly -> fixed

2009-06-14 released final version but without a credit part (will come later, if I find more time)

2009-06-16 minor: forgot to calculate font size when you change the window resolution (720x480 is optimized for collision detection - other window resolutions may not working properly for collision detection)

2009-06-17 minor: still overlooked font size parameteres and alien spaceship shoot parameters when windows sizes <> 720x480

2009-06-18 minor: some game settings added (will wait a few seconds after all asteroids have been destroyed) and added shadow at Asteroids label in About window

2009-07-01 minor: last update of the game code -> explosion of human spaceship fixed (copy/paste bug), change routine for copy bmp to GUI and added fps display counter

2009-12-21 minor: fixed some small bugs, replaced IsPressed() with WinAPI_GetKeyboardState function (thanks Eukalyptus), added latest Bass.dll, made game play specific modifications and changed code to be compatible with AutoIt v3.3.2.0!

2009-12-29 minor: forgot to undo silly modifications and added faster GDI+ backbuffer technique (thanks to AndyG for the idea)!

2011-04-12 minor: made small modifications, tried some optimizations (it is very hard to remember what I did in the code after a very long time of absence) :)

2011-04-29 minor: GUIRegisterMsg($WM_ERASEBKGND, "WM_ERASEBKGND") caused About window to look awful and added check for aero to place game graphic window to GUI more precise using _WinAPI_BitBlt()

2011-05-13 minor: cleaned up WinAPI display settings and forgot to undo About window settings.

2011-05-31 minor: speeded up game play by adding bitmaps instead of using one _WinAPI_CreateCompatibleBitmap(). I don't know why this is faster :P

2011-06-09 minor: changed FPS code because old code displayed too high FPS values

2012-07-30 minor: changed drawline function from integer to float to avoid wobbling of asteroids and spaceship

2016-01-14 minor: fixed code to run on AutoIt v3.3.14.2 when no highscore exists and changed GDI+ variable

Edited by UEZ
3 people like this

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

REALLY GOOD UEZ!!!

It's just like the real game... movement, sounds, feel-of-control, visuals.

I can even fly through the screen. I used to line up 2 rows of space ships on the pay-to-play game.

I do miss the ability to shoot 4 times in a row though. I used to lay-out a blanket of bullets for the ships.

Can this be added?

Thanks

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

REALLY GOOD UEZ!!!

It's just like the real game.

I can even fly through the screen. I used to line up 2 rows of space ships on the pay-to-play game.

I do miss the ability to shoot 4 times in a row though. Can this be added?

Thanks

8)

Thanks Valuater.

Yes, you are right - the code is not working properly ($amount_of_shoots_max = 4 is already set) :)

I put it also to my to do list :party:

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

Well Done UEZ!!, very nice game, I like the realistic movements

Share this post


Link to post
Share on other sites

Well Done UEZ!!, very nice game, I like the realistic movements

Thanks, the human ship movement was a lot easier than the other parts.

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

Amazing! 100% Amazing

Thank you so much lots of great work very much to be learned from the source. An amazing demonstration!


AutoIt changed my life.

Share this post


Link to post
Share on other sites

UEZ, good job!

Posted Image

Thanks.

Amazing! 100% Amazing

Thank you so much lots of great work very much to be learned from the source. An amazing demonstration!

Thanks for the feedback - currently I lost the overview over my code :)

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

you should remove bullet limit to make it more authentic


0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

you should remove bullet limit to make it more authentic

I wanted to make it 1:1 as much as possible - keep it simple with all its limitations!

I forgot to implement the explosion of the human space which is not an explosion of 10 pixel but breaks in several parts!

I will implement it in the next release.

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

#11 ·  Posted

This is absolutely fantastic!

Kudos, UEZ.

I wonder if this would speed collision detection?

;check space ship for border collision
                $z = $border_limes * $object_scale
                If $x < -$z Then $x = $width + $z
                If $x > $width + $z Then $x = -$z
                If $y < -$z Then $y = $height + $z
                If $y > $height + $z Then $y = -$z

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

This is absolutely fantastic!

Kudos, UEZ.

I wonder if this would speed collision detection?

;check space ship for border collision
                    $z = $border_limes * $object_scale
                    If $x < -$z Then $x = $width + $z
                    If $x > $width + $z Then $x = -$z
                    If $y < -$z Then $y = $height + $z
                    If $y > $height + $z Then $y = -$z
Thanks for feedback.

Btw, the check of the border is not the real problem but your are right :)

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

#13 ·  Posted

Thanks for feedback.

Btw, the check of the border is not the real problem but your are right :)

UEZ

Yes, I noticed that's not the "collision" that I'd like to see happening more often :party:

That area just jumped out at me. I'm good at cleanup, but all this GDI+stuff is greek to me.

How long ago did you start this?

I just have to say, again, I'm flabberghasted. Extremely impressed.

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Yes, I noticed that's not the "collision" that I'd like to see happening more often :)

That area just jumped out at me. I'm good at cleanup, but all this GDI+stuff is greek to me.

How long ago did you start this?

I just have to say, again, I'm flabberghasted. Extremely impressed.

I started it approx. 2 weeks ago but I had this in mind a long time ago (just dreamt of it).

Btw, how can I set up the music speed using bass.udf (_BASS_ChannelSetAttribute?)? Because the sound of the alien starship is too slow...

Thanks,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

#15 ·  Posted

UEZ this is just totally awesome. Kudos to you my friend. Here comes 5* :)

WBD

Share this post


Link to post
Share on other sites

#16 ·  Posted

UEZ this is just totally awesome. Kudos to you my friend. Here comes 5* :party:

WBD

Posted my 5 stars too! :)

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#18 ·  Posted

Way Cool UEZ! Jumpy for me but looks just like the orig....

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

The smaller files attached below seem to behave better...

Edit: I also tinkered with the definitions for the alien ship sounds to make them looping, then moved the Play() to the random statement that brings the ship out, so it's only called once. Then I put a ChannelStop in your alien_ship_reset routine. So it only starts the sound once when the ship appears and lets it loop until the ship is gone. Seems to sound real smooth with no pauses. I was playing with the control logic for the thump/thump game sounds too, so better make sure I didn;t screw it up. Anyway, it was easier to attach the changes in the whole file than paste them into this post. (Hope you don't mind me playing with your baby, I think it's pretty cool , and I guess I'm bored).

Edit: Deleted attachments to free up some disk space.

Edited by Spiff59

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

The smaller files attached below seem to behave better...

Edit: I also tinkered with the definitions for the alien ship sounds to make them looping, then moved the Play() to the random statement that brings the ship out, so it's only called once. Then I put a ChannelStop in your alien_ship_reset routine. So it only starts the sound once when the ship appears and lets it loop until the ship is gone. Seems to sound real smooth with no pauses. I was playing with the control logic for the thump/thump game sounds too, so better make sure I didn;t screw it up. Anyway, it was easier to attach the changes in the whole file than paste them into this post. (Hope you don't mind me playing with your baby, I think it's pretty cool , and I guess I'm bored).

Thanks Spiff59, the sound is really much smoother. I updated it (1st post)!

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • ViciousXUSMC
      Convert Multi-Page TIFF to Single Page
      By ViciousXUSMC
      So a little project I am working on.
      I sort of have this working via Irfanview using cmd scripting, but curious if it can be done in AutoIT maybe with GDI+ or any other native tool.
      I have an ancient microfilm scanner, and currently the only way it will scan is to take a full screen scan of 11x14 and make it a 2 page 8.5x11 Tiff Image.
      So this is cutting the image in half down the middle.
      What I need to do is have the 2nd page append to the first page on the right side, and then save the image as a single flat new image (Do not care about format very much)
      Any of the GDI wizards think this can be done? 
       
      Here is my starting point, I can open the image, convert the format to .jpg and flatten it (lose the 2nd page of the TIF)
      I have not quite figured out how to grab that 2nd page or do the append (panorama
       
       
      #Include <GDIPlus.au3> Local $hImage, $sCLSID _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Test3.tif") $sCLSID = _GDIPlus_EncodersGetCLSID("TIF") $sCLSID2 = _GDIPlus_EncodersGetCLSID("JPG") _GDIPlus_ImageSaveToFileEx($hImage, @ScriptDir & "\GDIPlus_Image2.jpg", $sCLSID2) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown()  
      Edit: got a lead on the multipage stuff: 
       
      And my code has grown into something where I am trying to draw an image ontop of the first image but it looks like it wont expand the canvas, but ultimately I was thinking just draw the 2nd page next to the 1st page once I figure out how to capture the 2nd page.
      #Include <GDIPlus.au3> Local $hImage, $sCLSID _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Test3.tif") $sCLSID = _GDIPlus_EncodersGetCLSID("TIF") $sCLSID2 = _GDIPlus_EncodersGetCLSID("JPG") $iWidth = _GDIPlus_ImageGetWidth($hImage) $iHeight = _GDIPlus_ImageGetHeight($hImage) ; Draw one image in another $hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage) _GDIPlus_GraphicsDrawImage($hGraphics, $hImage, $iWidth, $iHeight) _GDIPlus_ImageSaveToFileEx($hImage, @ScriptDir & "\GDIPlus_Image2.jpg", $sCLSID2) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown()  
    • InunoTaishou
      Redraw your desktop with GDI+
      By InunoTaishou
      Take a screenshot of your desktop (works even if the desktop is hidden), then redraws it row by row. Makes a neat little effect. An effect I remember seeing at the photo booth at Chuck E' Cheese.
      I mostly just wanted to mess with LockBits and PrintWindow and thought this was a decent way to figure it out, but I liked the outcome and thought I'd share lol
      #include <GDIPlus.au3> #include <WinApi.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() Global $tDesktopMetrics = GetDesktopMetrics() Global $hHBitmapDesktop = CaptureWindow("", -1, -1, -1, -1, "Program Manager") Global $hBitmapDesktop = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmapDesktop) _WinAPI_DeleteObject($hHBitmapDesktop) Global $iW = _GDIPlus_ImageGetWidth($hBitmapDesktop) Global $iH = _GDIPlus_ImageGetHeight($hBitmapDesktop) Global $tBitmapData = _GDIPlus_BitmapLockBits($hBitmapDesktop, 0, 0, $iW, $iH, $GDIP_ILMREAD, $GDIP_PXF32PARGB) Global $tPixelMap = DllStructCreate("int[" & $iW * $iH & "];", DllStructGetData($tBitmapData, "Scan0")) Global $hGui = GUICreate("Redraw", $iW, $iH, $tDesktopMetrics.x, $tDesktopMetrics.y, $WS_POPUP) Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui) Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphics) Global $tBitmapData2 = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $iW, $iH, $GDIP_ILMWRITE, $GDIP_PXF32PARGB) Global $tPixelMap2 = DllStructCreate("int[" & $iW * $iH & "];", DllStructGetData($tBitmapData2, "Scan0")) GUISetState(@SW_SHOW, $hGui) _GDIPlus_GraphicsClear($hGraphics) For $iY = 0 To $iH - 1 Local $iRowOffset = $iY * $iW + 1 For $iX = 0 To $iW - 1 ;get each pixel in each line and row DllStructSetData($tPixelMap2, 1, DllStructGetData($tPixelMap, 1, $iRowOffset + $iX), $iRowOffset + $iX) Next If (Not Mod($iY, 5)) Then ; Every 5 rows draw the bitmap _GDIPlus_BitmapUnlockBits($hBitmap, $tBitmapData2) _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0) $tBitmapData2 = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $iW, $iH, $GDIP_ILMWRITE, $GDIP_PXF32PARGB) $tPixelMap2 = DllStructCreate("int[" & $iW * $iH & "];", DllStructGetData($tBitmapData2, "Scan0")) EndIf Next If (Mod($iY, 5)) Then ; Didn't end on an even row, clean up _GDIPlus_BitmapUnlockBits($hBitmap, $tBitmapData2) _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0) $tPixelMap2 = 0 $tBitmapData2 = 0 EndIf _GDIPlus_BitmapUnlockBits($hBitmapDesktop, $tBitmapData) _GDIPlus_BitmapDispose($hBitmapDesktop) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() GUIDelete($hGui) Exit 0 Func GetDesktopMetrics() Return _GDIPlus_RectFCreate(_WinAPI_GetSystemMetrics($SM_XVIRTUALSCREEN), _WinAPI_GetSystemMetrics($SM_YVIRTUALSCREEN), _ _WinAPI_GetSystemMetrics($SM_CXVIRTUALSCREEN), _WinAPI_GetSystemMetrics($SM_CYFULLSCREEN)) EndFunc ;==>GetDesktopMetrics Func GetDialogMetrics() Local $tStruct = DllStructCreate("struct;long caption;long xBorder;long yBorder;long xDlgFrame;long yDlgFrame;endstruct") For $iSysMetric = $SM_CYCAPTION To $SM_CYDLGFRAME DllStructSetData($tStruct, $iSysMetric - $SM_CYCAPTION + 1, _WinAPI_GetSystemMetrics($iSysMetric)) Next Return $tStruct EndFunc ;==>GetDialogMetrics Func CaptureWindow($sFileName = "", $iLeft = -1, $iTop = -1, $iWidth = -1, $iHeight = -1, $hWnd = WinGetHandle("[Active]")) If (Not IsHWnd($hWnd)) Then $hWnd = WinGetHandle($hWnd) If (@error) Then Return SetError(1, 0, 0) Local $tDesktop = GetDesktopMetrics() Local $tRectFWindow = _WinAPI_GetWindowRect($hWnd) If ($iLeft = -1 Or $iLeft = Default) Then $iLeft = DllStructGetData($tDesktop, 1) If ($iTop = -1 Or $iLeft = Default) Then $iLeft = DllStructGetData($tDesktop, 2) If ($iWidth = -1 Or $iWidth = 0 Or $iWidth = Default) Then If ($hWnd = _WinAPI_GetDesktopWindow()) Then $iWidth = DllStructGetData($tDesktop, 3) Else $iWidth = DllStructGetData($tRectFWindow, 3) - DllStructGetData($tRectFWindow, 1) EndIf EndIf If ($iHeight = -1 Or $iHeight = 0 Or $iHeight = Default) Then If ($hWnd = _WinAPI_GetDesktopWindow()) Then $iHeight = DllStructGetData($tDesktop, 4) Else $iHeight = DllStructGetData($tRectFWindow, 4) - DllStructGetData($tRectFWindow, 2) EndIf EndIf Local $iWidth2 = $iWidth Local $iHeight2 = $iHeight If ($iLeft) Then $iWidth = Abs($iWidth - $iLeft) If ($iTop) Then $iHeight = Abs($iHeight - $iTop) Local $hDC = _WinAPI_GetWindowDC($hWnd) Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC) Local $hDestBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight) Local $hDestSv = _WinAPI_SelectObject($hDestDC, $hDestBitmap) Local $hSrcDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBmp = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth2, $iHeight2) Local $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hBmp) Local $tPoint = _WinAPI_CreatePoint($iLeft, $iTop) _WinAPI_PrintWindow($hWnd, $hSrcDC, True) _WinAPI_ScreenToClient($hWnd, $tPoint) _WinAPI_BitBlt($hDestDC, 0, 0, $iWidth, $iHeight, $hSrcDC, $iLeft, $iTop, $MERGECOPY) _WinAPI_SelectObject($hDestDC, $hDestSv) _WinAPI_SelectObject($hSrcDC, $hSrcSv) _WinAPI_ReleaseDC($hWnd, $hDC) _WinAPI_DeleteDC($hDestDC) _WinAPI_DeleteDC($hSrcDC) _WinAPI_DeleteObject($hBmp) $tPoint = 0 $tRectFWindow = 0 $tDesktop = 0 If ($sFileName = "") Then Return $hDestBitmap _GDIPlus_Startup() Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hDestBitmap) _WinAPI_DeleteObject($hDestBitmap) _GDIPlus_ImageSaveToFile($hBitmap, $sFileName) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() Return True EndFunc ;==>CaptureWindow  
    • scintilla4evr
      Combining GDI+ Paths with different combine modes
      By scintilla4evr
      When I was thinking about selections in Photoshop, I saw the resemblance to selection modes in GDI+ Regions. Then, I started to think how to apply these combine modes to Paths. So, here is a small script for this:

      Download
    • scintilla4evr
      Combining GDI+ Paths
      By scintilla4evr
      A small function for combining GDI+ Paths with different combine modes (like combining Regions).
    • InunoTaishou
      GDI+ Error description by code
      By InunoTaishou
      Was getting some errors in my GDI+ project and wanted to know what they actually were, since I don't know what Error code 4 is.... So I looked it up on MSDN and put together a function that would give return a description of the error based on the code.
      UDF:
      ; #FUNCTION# ==================================================================================================================== ; Name...........: _GDIPlus_GetErrorByCode ; Description....: Get the error message for the @Extended error when a _GDIPlus_* function fails. ; Syntax.........: _GDIPlus_GetErrorByCode ( [$iGDIError = @Extended [, Const $iReturnType = 0] ]) ; Parameters.....: $iGDIError - The error to retrieve. Default is the last @Extended code. ; $iReturnType - What type the return should be. 0 will return a string, any other value returns an array. ; - [0] Holds what type of error. ; - [1] Holds the description. ; Return values..: Success - The error based on the code given in the formate requested. ; Failure - The Error code given was out of range, not a valid code. ; Author.........: InunoTaishou ; Remarks........: Regardless of the error code a return in the format requested will be returned. If the code is out of range ; it will return an OutOfRange error. ; Related........: GDIPlus ; Link...........: https://msdn.microsoft.com/en-us/library/windows/desktop/ms534175%28v=vs.85%29.aspx ; Example........: Yes ; =============================================================================================================================== Func _GDIPlus_GetErrorByCode($iGDIError = @extended, Const $iReturnType = 0) Local Static $aErrors[22][2] = [["OK", "Indicates that the method call was successful."], _ ["GenericError", "Indicates that there was an error on the method call, which is identified as something other than those defined by the other elements of this enumeration."], _ ["InvalidParameter", "Indicates that one of the arguments passed to the method was not valid."], _ ["OutOfMemory", "Indicates that the operating system is out of memory and could not allocate memory to process the method call. For an explanation of how constructors use the OutOfMemory status, see the Remarks section at the end of this topic."], _ ["ObjectBusy", "Indicates that one of the arguments specified in the API call is already in use in another thread."], _ ["InsufficientBuffer", "Indicates that a buffer specified as an argument in the API call is not large enough to hold the data to be received."], _ ["NotImplemented", "Indicates that the method is not implemented."], _ ["Win32Error", "Indicates that the method generated a Win32 error."], _ ["WrongState", "Indicates that the object is in an invalid state to satisfy the API call. For example, calling Pen::GetColor from a pen that is not a single, solid color results in a WrongState status."], _ ["Aborted", "Indicates that the method was aborted."], _ ["FileNotFound", "Indicates that the specified image file or metafile cannot be found."], _ ["ValueOverflow", "Indicates that the method performed an arithmetic operation that produced a numeric overflow."], _ ["AccessDenied", "Indicates that a write operation is not allowed on the specified file."], _ ["UnknownImageFormat", "Indicates that the specified image file format is not known."], _ ["FontFamilyNotFound", "Indicates that the specified font family cannot be found. Either the font family name is incorrect or the font family is not installed."], _ ["FontStyleNotFound", "Indicates that the specified style is not available for the specified font family."], _ ["NotTrueTypeFont", "Indicates that the font retrieved from an HDC or LOGFONT is not a TrueType font and cannot be used with GDI+."], _ ["UnsupportedGdiplusVersion", "Indicates that the version of GDI+ that is installed on the system is incompatible with the version with which the application was compiled."], _ ["GdiplusNotInitialized", "Indicates that the GDI+API is not in an initialized state. To function, all GDI+ objects require that GDI+ be in an initialized state. Initialize GDI+ by calling GdiplusStartup."], _ ["PropertyNotFound", "Indicates that the specified property does not exist in the image."], _ ["PropertyNotSupported", "Indicates that the specified property is not supported by the format of the image and, therefore, cannot be set."], _ ["ProfileNotFound", "Indicates that the color profile required to save an image in CMYK format was not found."]] Return (($iGDIError <= 21 And $iGDIError >= 0) ? _ ($iReturnType = 0 ? $aErrors[$iGDIError][0] & ": " & $aErrors[$iGDIError][1] : StringSplit($aErrors[$iGDIError][0] & "|" & $aErrors[$iGDIError][1], "|", 2)) : _ ($iReturnType = 0 ? SetError(10, 0, "OutOfRange: Error code " & $iGDIError & " is out of range") : SetError(10, $iGDIError, StringSplit("OutOfRange" & "|" & "Error code " & $iGDIError & " is out of range", "|", 2)))) EndFunc ;==>_GDIPlus_GetErrorByCode Example:
      #include <Array.au3> #include <GDIPlus.au3> #include <GUIEdit.au3> _GDIPlus_Startup() Global Const $GUI_EVENT_CLOSE = -3 Global $hGui = GUICreate("GDI+ Error by code", 800, 500) Global $hEdit = _GUICtrlEdit_Create($hGui, "", 10, 300, 780, 190) Global $hPic = GUICtrlGetHandle(GUICtrlCreatePic("", 0, 0, 800, 290)) Global $hDc = _WinAPI_GetWindowDC($hPic) Global $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDc) Global $hPen = _GDIPlus_PenCreate(0xFF00FFFF, 6) Global $hFormat = _GDIPlus_StringFormatCreate() Global $hFontFamily = _GDIPlus_FontFamilyCreate("Segoe UI") Global $hFont = _GDIPlus_FontCreate($hFontFamily, 24) Global $tLaytout = _GDIPlus_RectFCreate(0, 0, 800, 290) Global $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000) Global $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Image1.jpg") Global $hFile = FileOpen(@ScriptDir & "\Image2.jpg", 16 + 1) _GDIPlus_StringFormatSetAlign($hFormat, 1) _GDIPlus_StringFormatSetLineAlign($hFormat, 1) GUISetState(@SW_SHOW, $hGui) Debug("Error generating calls" & @CRLF) Debug("Fake Font Family for _GDIPlus_FontFamilyCreate:" & _GDIPlus_FontFamilyCreate("AutoIt Rulez") & @CRLF & @TAB & _GDIPlus_GetErrorByCode() & @CRLF) Debug("Wrong Parameter for _GDIPlus_GraphicsClear: " & _GDIPlus_GraphicsClear(0, 0xFFF0F0F0) & @CRLF & @TAB & _GDIPlus_GetErrorByCode() & @CRLF) Debug("Load image for a file that's already open _GDIPlus_ImageLoadFromFile: " & _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Image2.jpg") & @CRLF & @TAB & _GDIPlus_GetErrorByCode() & @CRLF) Debug("Save image over a file that's already open _GDIPlus_ImageSaveToFile: " & _GDIPlus_ImageSaveToFile($hImage, @ScriptDir & "\Image2.jpg") & @CRLF & @TAB & _GDIPlus_GetErrorByCode() & @CRLF) _GDIPlus_ImageDispose($hImage) Debug("Dispose image that's already been disposed _GDIPlus_ImageDispose: " & _GDIPlus_ImageDispose($hImage) & @CRLF & @TAB & _GDIPlus_GetErrorByCode() & @CRLF) Debug(@CRLF & "Non error generating calls" & @CRLF) Debug("_GDIPlus_GraphicsClear: " & _GDIPlus_GraphicsClear($hGraphics, 0xFFF0F0F0) & @CRLF & @TAB & _GDIPlus_GetErrorByCode() & @CRLF) Debug("_GDIPlus_GraphicsDrawStringEx: " & _ _GDIPlus_GraphicsDrawStringEx($hGraphics, "This is a GDI+ UDF for getting the error message by @Extended code." & @CRLF & "Author: InunoTaishou", $hFont, $tLaytout, $hFormat, $hBrush) & _ @CRLF & @TAB & _GDIPlus_GetErrorByCode() & @CRLF) Debug("_GDIPlus_GraphicsDrawRect: " & _GDIPlus_GraphicsDrawRect($hGraphics, 2, 2, 796, 286, $hPen) & @CRLF & @TAB & _GDIPlus_GetErrorByCode() & @CRLF & @CRLF) Debug("All available errors:" & @CRLF & @TAB) For $i = 0 to 21 Debug($i & ": " & _GDIPlus_GetErrorByCode($i) & @CRLF & @TAB) Next _ArrayDisplay(_GDIPlus_GetErrorByCode(22, 1), "Error 22") Do Until (GUIGetMsg() = $GUI_EVENT_CLOSE) _WinAPI_ReleaseDC($hPic, $hDc) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_PenDispose($hPen) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_FontFamilyDispose($hFontFamily) _GDIPlus_BrushDispose($hBrush) FileClose($hFile) GUIDelete($hGui) Exit 0 Func Debug(Const $sMsg = "") _GUICtrlEdit_AppendText($hEdit, $sMsg) EndFunc ;==>Debug ; #FUNCTION# ==================================================================================================================== ; Name...........: _GDIPlus_GetErrorByCode ; Description....: Get the error message for the @Extended error when a _GDIPlus_* function fails. ; Syntax.........: _GDIPlus_GetErrorByCode ( [$iGDIError = @Extended [, Const $iReturnType = 0] ]) ; Parameters.....: $iGDIError - The error to retrieve. Default is the last @Extended code. ; $iReturnType - What type the return should be. 0 will return a string, any other value returns an array. ; - [0] Holds what type of error. ; - [1] Holds the description. ; Return values..: Success - The error based on the code given in the formate requested. ; Failure - The Error code given was out of range, not a valid code. ; Author.........: InunoTaishou ; Remarks........: Regardless of the error code a return in the format requested will be returned. If the code is out of range ; it will return an OutOfRange error. ; Related........: GDIPlus ; Link...........: https://msdn.microsoft.com/en-us/library/windows/desktop/ms534175%28v=vs.85%29.aspx ; Example........: Yes ; =============================================================================================================================== Func _GDIPlus_GetErrorByCode($iGDIError = @extended, Const $iReturnType = 0) Local Static $aErrors[22][2] = [["OK", "Indicates that the method call was successful."], _ ["GenericError", "Indicates that there was an error on the method call, which is identified as something other than those defined by the other elements of this enumeration."], _ ["InvalidParameter", "Indicates that one of the arguments passed to the method was not valid."], _ ["OutOfMemory", "Indicates that the operating system is out of memory and could not allocate memory to process the method call. For an explanation of how constructors use the OutOfMemory status, see the Remarks section at the end of this topic."], _ ["ObjectBusy", "Indicates that one of the arguments specified in the API call is already in use in another thread."], _ ["InsufficientBuffer", "Indicates that a buffer specified as an argument in the API call is not large enough to hold the data to be received."], _ ["NotImplemented", "Indicates that the method is not implemented."], _ ["Win32Error", "Indicates that the method generated a Win32 error."], _ ["WrongState", "Indicates that the object is in an invalid state to satisfy the API call. For example, calling Pen::GetColor from a pen that is not a single, solid color results in a WrongState status."], _ ["Aborted", "Indicates that the method was aborted."], _ ["FileNotFound", "Indicates that the specified image file or metafile cannot be found."], _ ["ValueOverflow", "Indicates that the method performed an arithmetic operation that produced a numeric overflow."], _ ["AccessDenied", "Indicates that a write operation is not allowed on the specified file."], _ ["UnknownImageFormat", "Indicates that the specified image file format is not known."], _ ["FontFamilyNotFound", "Indicates that the specified font family cannot be found. Either the font family name is incorrect or the font family is not installed."], _ ["FontStyleNotFound", "Indicates that the specified style is not available for the specified font family."], _ ["NotTrueTypeFont", "Indicates that the font retrieved from an HDC or LOGFONT is not a TrueType font and cannot be used with GDI+."], _ ["UnsupportedGdiplusVersion", "Indicates that the version of GDI+ that is installed on the system is incompatible with the version with which the application was compiled."], _ ["GdiplusNotInitialized", "Indicates that the GDI+API is not in an initialized state. To function, all GDI+ objects require that GDI+ be in an initialized state. Initialize GDI+ by calling GdiplusStartup."], _ ["PropertyNotFound", "Indicates that the specified property does not exist in the image."], _ ["PropertyNotSupported", "Indicates that the specified property is not supported by the format of the image and, therefore, cannot be set."], _ ["ProfileNotFound", "Indicates that the color profile required to save an image in CMYK format was not found."]] Return (($iGDIError <= 21 And $iGDIError >= 0) ? _ ($iReturnType = 0 ? $aErrors[$iGDIError][0] & ": " & $aErrors[$iGDIError][1] : StringSplit($aErrors[$iGDIError][0] & "|" & $aErrors[$iGDIError][1], "|", 2)) : _ ($iReturnType = 0 ? SetError(10, 0, "OutOfRange: Error code " & $iGDIError & " is out of range") : SetError(10, $iGDIError, StringSplit("OutOfRange" & "|" & "Error code " & $iGDIError & " is out of range", "|", 2)))) EndFunc ;==>_GDIPlus_GetErrorByCode