Sign in to follow this  
Followers 0
crashdemons

[Game] StarShooter

42 posts in this topic

#1 ·  Posted (edited)

I had this FINISHED, lying around, waiting to be released here but I never got around to it.

Now, here it is.

Note 1: this is NOT using any images - it is only drawing-based!

The sounds for this particular project were shamelessly ripped from elsewhere.

Please let me know if it is too hard or too easy - more things can be added/changed!

Posted Image

StarShooter.zip

Known Bugs:

Enemy phaser lines sometimes rarely draw towards 0,0 instead of towards you. Fixed

If you go off-screen [wrapped] too many times or fly straight for too long, enemies clump/merge together on top of each other.

Edited by crashdemons
1 person likes this

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites



can you make it so you move a bit faster or the enemies move a bit slower, its impossible to shake 4 guys off i they are a couple of pixels behind you!

Very nice though.

MDiesel

Share this post


Link to post
Share on other sites

I'm glad you like it, Yashied - I would like to add a story and some preset animations whenever time permits.

(a space for an animation is already reserved before the final level [the non-existant $level=14] ; a cheat code (the D key) already uses an animation)


My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites

I had this FINISHED, lying around, waiting to be released here but I never got around to it.

Now, here it is.

Note 1: this is NOT using any images - it is only drawing-based!

Note 2: I had a complaint about the Sounds not playing so I made them all 8-bit PCM - not sure if it will help or not.

The sounds for this particular project were shameless ripped from elsewhere.

Please let me know if it is too hard or too easy - more things can be added/changed!

Posted Image

Known Bugs:

Enemy phaser lines sometimes rarely draw towards 0,0 instead of towards you.

Looks really nice!

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

#6 ·  Posted (edited)

can you make it so you move a bit faster or the enemies move a bit slower, its impossible to shake 4 guys off i they are a couple of pixels behind you!

Very nice though.

MDiesel

You don't have to shake them, you have one thing your empire buddies don't - reverse thrusters.

Try using the Down arrow.

If _IsPressed($Keys[2]) Then $AMoveS=-1; reverse - on a spaceship!? I think not!
Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites

Nice game, I found also a trick to win, if u stay in the middle of the bottom u win easy ( until the enemy move very fast )

Share this post


Link to post
Share on other sites

Maybe I should make it so if you get to the edge of the screen you can't fire :)

(or corner-camp for that matter)


My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites

or possibly so you can go off one end and come out the other, that would make it real oldskool!

Its kinda addictive...

MDiesel

Share this post


Link to post
Share on other sites

I found another trick/bug:

whenever u do the animation pressing D, enemies stop firing, so spamming the animation makes u unbeatable, but after pressing D some times u will not able to do nothing

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Cool game, but I have 2 observations.

1. I never heard any sounds.

2. It gives a laggy feeling.

1.

See? i don't know why you and others have problems with this - it works fine here, and all I'm doing is using _SoundOpen, _SoundPlay (using the textual sound "alias").

Additionally, all of the WAV's are 8-bit mono tracks which there shouldn't be any problem playing...

A couple of questions:

Are you extracting all of the files to a folder before running (not just running from the ZIP)?

What AutoIt version are you using?

I'm still using 3.2.12.1 because of changes in later versions.

What OS are you on by chance? - If Vista, did you try Run as Admin? (just to open a WAV file?)

I'll try to add some error-checking for the _Sound* functions in the next update.

PS: Was anyone who tested this able to hear the sounds?

2.

I'm not sure much could be done about that - only necessary data is contained in all of the arrays and the checking that is done is all required for decent operation.

You could always lower that measly Sleep(50) if you had a fast PC, but personally I wouldn't......

The things that really slow it noticeably is having too many things to draw, which is why there is a cap to the "shots" and the collisions/explosions.

I'll look into whether there's any optimizations possible for the multiple things that occur.

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites

1.

All files extracted to a folder calles StarShooter on my desktop.

Running with AutoIt 3.3.0.0 (it could matter since there was a big rewrite on the sound udf on that version. What version is your AutoIt?).

Windows XP Professional SP3. Account is in Admin group.

2.

Good tip, I changed the Sleep to 25 and it was better looking and a little harder. Much more my style now :)

Share this post


Link to post
Share on other sites

I cant hear the sound too (the same as AdmiralAlkex but SP2)

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

I found another trick/bug:

whenever u do the animation pressing D, enemies stop firing, so spamming the animation makes u unbeatable, but after pressing D some times u will not able to do nothing

D is a cheat - I made it so that attacks stopped, if you investigate the code you'll see this:

(The starburst is animation 1)

Func AnimCheck()
    Switch $AnimationN
        Case 0
            
        Case 1
            $CanFire=False
          ...

I made it so that attacks also resume after the fact, but sometimes level-changes interfere.

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

1.

All files extracted to a folder calles StarShooter on my desktop.

Running with AutoIt 3.3.0.0 (it could matter since there was a big rewrite on the sound udf on that version. What version is your AutoIt?).

Windows XP Professional SP3. Account is in Admin group.

2.

Good tip, I changed the Sleep to 25 and it was better looking and a little harder. Much more my style now :party:

I'm using AutoIt 3.2.12.1 because I still write programs for Win98/Win2k etc.

I should try to find out if there's a quick way to switch between AutoIt versions so I can compile programs with either set: legacy or updated.

Personally though, I dislike the idea of having two sets of includes folders - having both seems like a headache either way.

:)

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites

Imagination is very important.

Obviously you are in no lack of it. 5 stars from me.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

I'm using AutoIt 3.2.12.1 because I still write programs for Win98/Win2k etc.

I should try to find out if there's a quick way to switch between AutoIt versions so I can compile programs with either set: legacy or updated.

Personally though, I dislike the idea of having two sets of includes folders - having both seems like a headache either way.

:)

That explains it. I had to make all sorts of ugly fixes to 2 of my scripts after upgrading to 3.3.0.0, the Sound UDF have lots of changes (mostly irritating ones).

Share this post


Link to post
Share on other sites

Update: I added a quick and dirty fix for sounds. (not really efficient - optimizations will occur later)

Sounds should now work with the updated Sound UDF, but not on the old one.

I downloaded AutoIt v3.3 today and tested it out.


My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

I just updated the script - I've had time to work on it lately and I added and changed a number of things.

Tell me if the script is too hard to finish - I should be able to make it easier with some input.

Animations must now finish before level changes (Fixed starburst cheat hanging on last level)

Enemies were originally allowed to fire phasers if destroyed by phasers (Fixed phaser lines drawing to 0,0)

Wrong array indices were being used in one area. (Fixed jumpy/non-smooth enemy movement etc.)

A number of sections have had the passed information changed to ByRef

The shortest turning angle is now used in conditions - yeilding smarter choices for the computer.

Enemies are now spawned facing at random angles - instead of all 0 degrees.

The dreadnought (the Big Ship) was way too easy - you have to deal with another weapon now.

The dreadnought will also be making unscheduled visits [animation] with it's new gun - reduces camping.

Nearly all "shots" and ships will now wrap from off-screen. (excluding the dread's shiny new weapon)

Unfixed Bug:

If you go off-screen [wrapped] too many times or fly straight for too long, enemies clump/merge together on top of each other while pursuing you.

Let me know what you think.

And now the spoilers:

Cheat 2:

'A', skip to the last level after the current.

Cheat 3:

'S', manually trigger a "visit" from the Dreadnought

The Dread's Weapon is:

A torpedo that starburst-explodes when it hits ANYTHING solid.

Hitting this torpedo head-on may, in many cases, be a near-death experience

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

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
Sign in to follow this  
Followers 0

  • Similar Content

    • c.haslam
      By c.haslam
      In my code, the mouse wheel causes the line to move up and down. It does move down to where the picture is, but is not seen there. This can be observed by scrolling down to the picture, and then up again: the line reappears as expected.
      How can I get the line to show on the picture? This seems to be a matter of transparency, but I have not found a way of getting the background of $graphLine to be transparent.
      The code is now:
      #include <ButtonConstants.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars',1) Global Const $MK_SHIFT = 0x4 Global Const $MK_CONTROL = 0x8 GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL") Global $gY0,$gY1,$gForm1,$glblLine,$glblPic main() Func main() $gForm1 = GUICreate("Form1", 623, 601, 192, 114) $glblLine = GUICtrlCreateLabel("", 8, 8, 604, 137) $glblPic = GUICtrlCreateLabel("", 8, 8, 589, 500) Local $btn = GUICtrlCreateButton("Rotate", 472, 560, 65, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Local $oldY0,$oldY1 _GDIPlus_Startup() Local $h = GUICtrlGetHandle($glblLine) ; limit graphics to area of $label Local $GraphicLine = _GDIPlus_GraphicsCreateFromHWND($h) Local $hPen = _GDIPlus_PenCreate(0xFF000000,2) Local $image = _GDIPlus_ImageLoadFromFile('H:\a\P5130021.jpg') Local $h = GUICtrlGetHandle($glblPic) Local $GraphicPic = _GDIPlus_GraphicsCreateFromHWND($h) _GDIPlus_GraphicsDrawImage($GraphicPic,$image,0,0) $gY0 = 67 $gY1 = 67 _GDIPlus_GraphicsClear($GraphicLine,0) _GDIPlus_GraphicsDrawLine($GraphicLine, 10, $gY0, 350, $gY1, $hPen) ; Loop until the user exits. While True If $gY0<>$oldY0 Or $gY1<>$oldY1 Then _GDIPlus_GraphicsClear($GraphicLine,0xFFD4D0C8) _GDIPlus_GraphicsDrawLine($GraphicLine, 10, $gY0, 590, $gY1, $hPen) $oldY0 = $gY0 $oldY1 = $gY1 Else Switch GUIGetMsg() Case $GUI_EVENT_CLOSE,$btn Exit EndSwitch EndIf WEnd ; Clean up resources _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($GraphicLine) _GDIPlus_Shutdown() EndFunc Func WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam Local Const $ymax=500 Local $vec = GUIGetCursorInfo($gForm1) If $vec[4] = $glblLine Or $vec[4]=$glblPic Then Local $iDelta = BitShift($wParam, 16) ; positive = up Local $iKeys = _WinAPI_LoWord($wParam) If BitAND($iKeys,$MK_CONTROL)=$MK_CONTROL Then If BitAND($iKeys,$MK_SHIFT)=$MK_SHIFT Then ; do nothing Else If $iDelta > 0 And $gY0>3 Then $gY0 -= 1 If $iDelta < 0 And $gY0<$ymax Then $gY0 += 1 EndIf Else If BitAND($iKeys,$MK_SHIFT)=$MK_SHIFT Then If $iDelta > 0 And $gY1>3 Then $gY1 -= 1 If $iDelta < 0 And $gY1<$ymax Then $gY1 += 1 Else If $iDelta > 0 And $gY0>3 Then $gY0 -= 1 If $iDelta < 0 And $gY0<$ymax Then $gY0 += 1 If $iDelta > 0 And $gY1>3 Then $gY1 -= 1 If $iDelta < 0 And $gY1<$ymax Then $gY1 += 1 EndIf EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_MOUSEWHEEL Some other questions:
      Do I really need GDI+, or is there a simpler way? My code creates Graphics (canvases?) from labels. Is this legitimate? I have found MSDN to be un-helpful in learning GDI+. Is there a better learning tool?
    • spudw2k
      By spudw2k
      Here's a fun tool I put together.  It's a Plasma sandbox.  More features to come.

      This page was a useful resource for learning about this kind of Plasma implementation.
      Warning! Not Epileptic Friendly (probably)! Use at own Risk!
      I tried to curve the "default/initial" Plasma patterns so they aren't too erratic.  That doesn't mean you can't alter the Plasmas to be more erratic.  If you are sensitive to flashing colors and lights, use due caution.  
      #Region - Includes and Globals #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ComboConstants.au3> #include <GuiComboBox.au3> #include <SliderConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include <Misc.au3> ;#include <Array.au3> Opt("GUIOnEventMode", 1) Local $hDLL = DllOpen("user32.dll") Global Const $iWinMinWidth = @DesktopWidth * .25 Global Const $iWinMinHeight = @DesktopHeight * .25 Global $bIsPlaying = True, $bIsDrawing = False Global $hTimerFPS Global $iRows = 16, $iCols = 16 Global $iDisplayPlasma = 0, $iSelectPlasma = 0 Global $aPlasmaShapes[4] = ["($iX)", "($iY)", "($iX + $iY)", "Sqrt(($iX * $iX) + ($iY * $iY))"] ;~ Global $aPlasmas[4][7] = [[0, Random(6, 14, 1), 0, 0, 1, 0, 0], [1, Random(6, 14, 1), 0, 0, 0, 0, 0], [2, Random(8, 16,1 ), 0, 0, 1, 0, 0], [3, Random(8, 16, 1), 0, 0, Random(0,1,1), 0, 0]] ;Sine Wave | Spread | Position | Rotation | Spread Motion | Position Motion | Rotation Motion Global $aPlasmas[4][7] = [[0, Random(6, 14, 1), 0, 0, 0, 0, 0], [1, Random(6, 14, 1), 0, 0, 0, 0, 0], [2, Random(8, 16,1 ), 0, 0, 0, 0, 0], [3, Random(8, 16, 1), 0, 0, 0, 0, 0]] ;Sine Wave | Spread | Position | Rotation | Spread Motion | Position Motion | Rotation Motion Global $aPallete[256] Global $aPalleteSettings[3][3] = [[0, 128, 128], [-1.75, 128, 128], [1.75, 128, 128]] ;Position | Spread | Value Global $aPalleteDefaults = $aPalleteSettings Global $iPalleteShift = 0, $bPalleteShift = True, $iPalletShiftDirection = -5 #EndRegion - Includes and Globals #Region - Main GUI Global $aGUI[1] = ["id|hWnd"] Global Enum $hGUI = 1, $idMnuFile, $idMnuFileExit, $idMnuFilePlay, $idMnuOptions, $idMnuOptionsPallete, $idMnuOptionsPalleteShift, $idMnuOptionsEditor, $idMnuOptionsZoom, $idMnuOptionsZoomIn, $idMnuOptionsZoomOut, $iGUILast ReDim $aGUI[$iGUILast] Global Const $sVersion = "0.1" Global Const $sTitle = "Plasma_kIt - Version " & $sVersion $aGUI[$hGUI] = GUICreate($sTitle, $iWinMinWidth, $iWinMinHeight, -1, -1, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX)) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $aGUI[$idMnuFile] = GUICtrlCreateMenu("&File") $aGUI[$idMnuFilePlay] = GUICtrlCreateMenuItem("&Pause", $aGUI[$idMnuFile]) GUICtrlSetOnEvent(-1, "_PlayToggle") $aGUI[$idMnuFileExit] = GUICtrlCreateMenuItem("E&xit", $aGUI[$idMnuFile]) GUICtrlSetOnEvent(-1, "_Exit") $aGUI[$idMnuOptions] = GUICtrlCreateMenu("&Options") $aGUI[$idMnuOptionsPallete] = GUICtrlCreateMenuItem("Pallete Mixer", $aGUI[$idMnuOptions]) GUICtrlSetOnEvent(-1, "_GUIPallete_Show") $aGUI[$idMnuOptionsPalleteShift] = GUICtrlCreateMenuItem("Pallete Shift", $aGUI[$idMnuOptions]) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlSetOnEvent(-1, "_GUIPallete_ShiftToggle") $aGUI[$idMnuOptionsEditor] = GUICtrlCreateMenuItem("Plasma Editor", $aGUI[$idMnuOptions]) GUICtrlSetOnEvent(-1, "_GUIPlasmaEditor_Show") $aGUI[$idMnuOptionsZoom] = GUICtrlCreateMenu("Zoom", $aGUI[$idMnuOptions]) $aGUI[$idMnuOptionsZoomIn] = GUICtrlCreateMenuItem("Zoom In" & @TAB & "+", $aGUI[$idMnuOptionsZoom]) GUICtrlSetOnEvent(-1, "_Zoom") $aGUI[$idMnuOptionsZoomOut] = GUICtrlCreateMenuItem("Zoom Out" & @TAB & "-", $aGUI[$idMnuOptionsZoom]) GUICtrlSetOnEvent(-1, "_Zoom") _GDIPlus_Startup() ;Start GDI+ UDF Global Const $hDC = _WinAPI_GetDC($aGUI[$hGUI]) Global Const $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC, @DesktopWidth, @DesktopHeight) Global Const $hDC_backbuffer = _WinAPI_CreateCompatibleDC($hDC) Global Const $DC_obj = _WinAPI_SelectObject($hDC_backbuffer, $hHBitmap) $hBackbuffer = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer) ;_GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing) $hBrush = _GDIPlus_BrushCreateSolid(0x00000000) ;Brush for Coloring/Painting LED Pixels Local $aAccelKeys[5][2] = [["{+}", $aGUI[$idMnuOptionsZoomIn]], ["{NUMPADADD}", $aGUI[$idMnuOptionsZoomIn]], ["{-}", $aGUI[$idMnuOptionsZoomOut]], ["{NUMPADSUB}", $aGUI[$idMnuOptionsZoomOut]], ["{pause}", $aGUI[$idMnuFilePlay]]] GUISetAccelerators($aAccelKeys) #EndRegion - Main GUI #Region - Pallete Mixer GUI Global $aGUIPallete[1] = ["id|hWnd"] Global Enum $hGUIPallete = 1, $idSliderRPosition, $idSliderRValue, $idSliderRSpread, $idSliderGPosition, $idSliderGValue, _ $idSliderGSpread, $idSliderBPosition, $idSliderBValue, $idSliderBSpread, $idBtnResetPallete, $iGUIPalleteLast ReDim $aGUIPallete[$iGUIPalleteLast] $aGUIPallete[$hGUIPallete] = GUICreate("Pallete Mixer", 338, 260, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "_GUIPallete_Hide") $aGUIPallete[$idSliderRPosition] = GUICtrlCreateSlider(8, 132, 97, 33, $TBS_ENABLESELRANGE) GUICtrlSetLimit(-1, 20, -20) ;~ GUICtrlSetOnEvent(-1, "_GUIPallete_SettingsChange") $aGUIPallete[$idSliderRValue] = GUICtrlCreateSlider(48, 56, 33, 73, BitOR($TBS_VERT, $TBS_ENABLESELRANGE)) GUICtrlSetLimit(-1, 128, 0) ;~ GUICtrlSetOnEvent(-1, "_GUIPallete_SettingsChange") $aGUIPallete[$idSliderRSpread] = GUICtrlCreateSlider(8, 168, 97, 33, $TBS_ENABLESELRANGE) GUICtrlSetLimit(-1, 24, 2) ;~ GUICtrlSetOnEvent(-1, "_GUIPallete_SettingsChange") $aGUIPallete[$idSliderGPosition] = GUICtrlCreateSlider(120, 132, 97, 33, $TBS_ENABLESELRANGE) GUICtrlSetLimit(-1, 20, -20) ;~ GUICtrlSetOnEvent(-1, "_GUIPallete_SettingsChange") $aGUIPallete[$idSliderGValue] = GUICtrlCreateSlider(160, 56, 33, 73, BitOR($TBS_VERT, $TBS_ENABLESELRANGE)) GUICtrlSetLimit(-1, 128, 0) ;~ GUICtrlSetOnEvent(-1, "_GUIPallete_SettingsChange") $aGUIPallete[$idSliderGSpread] = GUICtrlCreateSlider(120, 168, 97, 33, $TBS_ENABLESELRANGE) GUICtrlSetLimit(-1, 24, 2) ;~ GUICtrlSetOnEvent(-1, "_GUIPallete_SettingsChange") $aGUIPallete[$idSliderBPosition] = GUICtrlCreateSlider(232, 132, 97, 33, $TBS_ENABLESELRANGE) GUICtrlSetLimit(-1, 20, -20) ;~ GUICtrlSetOnEvent(-1, "_GUIPallete_SettingsChange") GUICtrlSetData(-1, 9) $aGUIPallete[$idSliderBValue] = GUICtrlCreateSlider(272, 56, 33, 73, BitOR($TBS_VERT, $TBS_ENABLESELRANGE)) GUICtrlSetLimit(-1, 128, 0) ;~ GUICtrlSetOnEvent(-1, "_GUIPallete_SettingsChange") $aGUIPallete[$idSliderBSpread] = GUICtrlCreateSlider(232, 168, 97, 33, $TBS_ENABLESELRANGE) GUICtrlSetLimit(-1, 24, 2) GUICtrlSetData(-1, 11) ;~ GUICtrlSetOnEvent(-1, "_GUIPallete_SettingsChange") GUICtrlCreateLabel("RED", 46, 200, 30, 20) GUICtrlCreateLabel("GREEN", 150, 200, 38, 20) GUICtrlCreateLabel("BLUE", 268, 200, 30, 20) $aGUIPallete[$idBtnResetPallete] = GUICtrlCreateButton("Reset", 136, 236, 67, 17) GUICtrlSetOnEvent(-1, "_GUIPallete_Reset") GUISetAccelerators($aAccelKeys) Global Const $hDCPallete = _WinAPI_GetDC($aGUIPallete[$hGUIPallete]) Global Const $hHBitmapPallete = _WinAPI_CreateCompatibleBitmap($hDCPallete, 320, 40) Global Const $hDC_backbufferPallete = _WinAPI_CreateCompatibleDC($hDCPallete) Global Const $DC_objPallete = _WinAPI_SelectObject($hDC_backbufferPallete, $hHBitmapPallete) Global Const $hBackbufferPallete = _GDIPlus_GraphicsCreateFromHDC($hDC_backbufferPallete) Global $hBrushPallete = _GDIPlus_BrushCreateSolid(0xFF000000) ;~ _GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing) _GUIPallete_Update() _GUIPallete_Reset() #EndRegion - Pallete Mixer GUI #Region - Plasma Editor GUI Global $aGUIPlasmaEditor[1] = ["id|hWnd"] Global Enum $hGUIPlasmaEditor = 1, $idCmbPlasmaSelector, $idCmbPlasmaDisplay, $idBtnPlasmaAdd, $idBtnPlasmaDel, $idCmbPlasmaShape, $idSliderPlasmaSpread, $idCmbPlasmaSpread, $idSliderPlasmaRotation, $idCmbPlasmaRotation, $idSliderPlasmaPosition, $idCmbPlasmaPosition, $iGUIPlasmaEditorLast ReDim $aGUIPlasmaEditor[$iGUIPlasmaEditorLast] $aGUIPlasmaEditor[$hGUIPlasmaEditor] = GUICreate("Plasma Editor", 419, 323, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "_GUIPlasmaEditor_Hide") GUICtrlCreateLabel("Display", 16, 8, 95, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $aGUIPlasmaEditor[$idCmbPlasmaDisplay] = GUICtrlCreateCombo("", 16, 24, 121, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "All Combined|Selected Plasma", "All Combined") GUICtrlSetOnEvent(-1, "_GUIPlasmaEditor_PlasmaDisplay") GUICtrlCreateLabel("Selected Plasma", 24, 96, 120, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $aGUIPlasmaEditor[$idBtnPlasmaAdd] = GUICtrlCreateButton("Add Plasma", 160, 16, 113, 33) GUICtrlSetOnEvent(-1, "_GUIPlasmaEditor_PlasmaAddRem") GUICtrlSetState(-1, $GUI_DISABLE) $aGUIPlasmaEditor[$idBtnPlasmaDel] = GUICtrlCreateButton("Remove Plasma", 296, 16, 113, 33) GUICtrlSetOnEvent(-1, "_GUIPlasmaEditor_PlasmaAddRem") GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateGroup("Plasma Controls", 8, 64, 401, 249) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $aGUIPlasmaEditor[$idCmbPlasmaSelector] = GUICtrlCreateCombo("", 24, 112, 121, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "Plasma #1|Plasma #2|Plasma #3|Plasma #4", "Plasma #1") GUICtrlSetOnEvent(-1, "_GUIPlasmaEditor_PlasmaSelect") GUICtrlCreateLabel("Shape", 174, 96, 35, 17) $aGUIPlasmaEditor[$idCmbPlasmaShape] = GUICtrlCreateCombo("", 174, 112, 113, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "Horizontal|Vertical|Diagonal|Circular", "Horizontal") GUICtrlSetOnEvent(-1, "_GUIPlasmaEditor_PlasmaSetShape") GUICtrlCreateLabel("Spread", 24, 145, 38, 17) $aGUIPlasmaEditor[$idSliderPlasmaSpread] = GUICtrlCreateSlider(16, 160, 257, 25, $TBS_FIXEDLENGTH) GUICtrlSetLimit(-1, 255, 5) $aGUIPlasmaEditor[$idCmbPlasmaSpread] = GUICtrlCreateCombo("", 280, 160, 113, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "Static|Oscillate", "Static") GUICtrlSetOnEvent(-1, "_GUIPlasmaEditor_PlasmaSetSpread") GUICtrlCreateLabel("Rotation", 24, 201, 44, 17) GUICtrlSetState(-1, $GUI_DISABLE) $aGUIPlasmaEditor[$idSliderPlasmaRotation] = GUICtrlCreateSlider(16, 216, 257, 25, $TBS_FIXEDLENGTH) GUICtrlSetState(-1, $GUI_DISABLE) $aGUIPlasmaEditor[$idCmbPlasmaRotation] = GUICtrlCreateCombo("", 280, 216, 113, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "Static|Oscillate", "Static") GUICtrlSetOnEvent(-1, "_GUIPlasmaEditor_PlasmaSetRotation") GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateLabel("Position", 24, 257, 41, 17) GUICtrlSetState(-1, $GUI_DISABLE) $aGUIPlasmaEditor[$idSliderPlasmaPosition] = GUICtrlCreateSlider(16, 272, 257, 25, $TBS_FIXEDLENGTH) GUICtrlSetLimit(-1, 127, -127) GUICtrlSetState(-1, $GUI_DISABLE) $aGUIPlasmaEditor[$idCmbPlasmaPosition] = GUICtrlCreateCombo("", 280, 272, 113, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "Static|Oscillate", "Static") GUICtrlSetOnEvent(-1, "_GUIPlasmaEditor_PlasmaSetPosition") GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateGroup("", -99, -99, 1, 1) _GUIPlasmaEditor_PlasmaSettingsLoad($iSelectPlasma) ;_GUIPlasmaEditor_PlasmaControlsLock() GUISetAccelerators($aAccelKeys) #EndRegion - Plasma Editor GUI #Region - Initialization and Main Loop GUIRegisterMsg($WM_GETMINMAXINFO, "_WM_GETMINMAXINFO") GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") GUISetState(@SW_SHOW, $aGUI[$hGUI]) While 1 If $bIsPlaying And Not $bIsDrawing Then _DrawScreen(_RenderPlasma()) Sleep(10) WEnd #EndRegion - Initialization and Main Loop #Region - Main GUI Functions Func _DrawScreen($aPixels) ;If Function called while Drawing Return 0 If $bIsDrawing Then Return 0 ;Set Drawing Status Indictaor $bIsDrawing = True ;Create Timer for Drawing Performance/Duration Local $hTimer = TimerInit() ;Erase Bitmap Graphic _GDIPlus_GraphicsClear($hBackbuffer, 0xFFFFFFFF) ;Capture Client Window Size $aWinClientSize = WinGetClientSize($aGUI[$hGUI]) ;Setup Variables Local $iPixelIndex = 0 Local $iCol = $iCols Local $iRow = $iRows Local $iWidth = $aWinClientSize[0] / $iCol Local $iHeight = $aWinClientSize[1] / $iRow ;Draw Pixel Grid (Top-Left to Bottom Right) For $iY = 0 To $iRow - 1 For $iX = 0 To $iCol - 1 Local $dARGB = $aPixels[$iPixelIndex] ;Set Brush Color _GDIPlus_BrushSetSolidColor($hBrush, $dARGB) ;Draw "Pixel" _GDIPlus_GraphicsFillRect($hBackbuffer, $iX * $iWidth, $iY * $iHeight, $iWidth, $iHeight, $hBrush) ;Increment Pixel Counter $iPixelIndex += 1 If $iPixelIndex = UBound($aPixels) Then $iPixelIndex = 0 Next Next ;Draw Bitmap to Screen _WinAPI_BitBlt($hDC, 0, 0, $aWinClientSize[0], $aWinClientSize[1], $hDC_backbuffer, 0, 0, $SRCCOPY) ;blit drawn bitmap to GUI ;FPS Counter $hTimer = TimerDiff($hTimer) ;~ ConsoleWrite("Whole Process time: " & Round($hTimer / 1000, 3) & @CRLF) If $bIsPlaying Then If TimerDiff($hTimerFPS) >= 998 Then Local $iFPS = Round(1000 / $hTimer, 2) WinSetTitle($aGUI[$hGUI], "", $sTitle & " (" & $iFPS & " FPS) " & $iCols & " x " & $iRows) $hTimerFPS = TimerInit() EndIf Else ;Show FPS in Window Title WinSetTitle($aGUI[$hGUI], "", $sTitle) EndIf $bIsDrawing = False EndFunc ;==>_DrawScreen Func _Exit() ; Clean up resources _GUIPallete_Exit() GUIDelete($aGUIPallete[$hGUIPallete]) GUIDelete($aGUIPlasmaEditor[$hGUIPlasmaEditor]) GUIDelete($aGUI[$hGUI]) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hBackbuffer) _WinAPI_SelectObject($hDC, $DC_obj) _WinAPI_DeleteObject($hHBitmap) _WinAPI_ReleaseDC($hGUI, $hDC) _GDIPlus_Shutdown() DllClose($hDLL) Exit EndFunc ;==>_Exit Func _PlayToggle() ;Toggle Play State If Not $bIsPlaying Then ;Start Playing $bIsPlaying = True $hTimerFPS = TimerInit() GUICtrlSetData($aGUI[$idMnuFilePlay], "&Pause") Else ;Stop Playing $bIsPlaying = False GUICtrlSetData($aGUI[$idMnuFilePlay], "&Play") EndIf EndFunc ;==>_PlayToggle Func _RenderPlasma() ;Setup Variables Local $aWorkPallete = $aPallete Local $iRow = $iRows Local $iCol = $iCols Local $iGridSize = $iRow * $iCol Local $aPixels[$iGridSize] Local $iIndex = 0 Local $iPlasma = 0 Local $iPlasmas Local $iDisplayPlasmaNumber = $iDisplayPlasma Local $iSine, $iSpread, $iPosition ;Loop Through Pixel Grid and Calculate Plasma(s) For $iY = 0 To $iRow - 1 For $iX = 0 To $iCol - 1 $iPlasmas = 0 If Not $iDisplayPlasmaNumber Then For $iZ = 0 To UBound($aPlasmas) - 1 $iSine = $aPlasmas[$iZ][0] ;Spread Motions If $aPlasmas[$iZ][4] Then $aPlasmas[$iZ][4] += ($aPlasmas[$iZ][1] * 0.00001125) $iSpread = -7*Sin($aPlasmas[$iZ][4])+9 Else $iSpread = $aPlasmas[$iZ][1] EndIf $iPosition = $aPlasmas[$iZ][2] $iPlasma = Execute("128.0 + (128.0 * Sin(" & $aPlasmaShapes[$iSine] & " / " & $iSpread & "))") $iPlasmas += $iPlasma Next Else $iSine = $aPlasmas[$iDisplayPlasmaNumber - 1][0] ;Spread Motions If $aPlasmas[$iDisplayPlasmaNumber - 1][4] Then $aPlasmas[$iDisplayPlasmaNumber - 1][4] += ($aPlasmas[$iDisplayPlasmaNumber - 1][1] * 0.005) $iSpread = Sin($aPlasmas[$iDisplayPlasmaNumber - 1][4])/2 Else $iSpread = $aPlasmas[$iDisplayPlasmaNumber - 1][1] EndIf $iPosition = $aPlasmas[$iDisplayPlasmaNumber - 1][2] ;$iPlasmas = Execute("128.0 + (128.0 * Sin(" & $aPlasmaShapes[$aPlasmas[$iDisplayPlasmaNumber - 1][0]] & " / " & $aPlasmas[$iDisplayPlasmaNumber - 1][1] & ") - " & $aPlasmas[$iDisplayPlasmaNumber - 1][2] & ")") $iPlasmas = Execute("128.0 + (128.0 * Sin(" & $aPlasmaShapes[$iSine] & " / " & $iSpread & "))") EndIf $iPlasma = Int($iPlasmas) ;Account for Pallete Shift $iPlasma += $iPalleteShift ;Wrap Pixel Pallete Color If $iPlasma >= 256 Then Do $iPlasma -= 256 Until $iPlasma < 256 EndIf If $iPlasma <= -1 Then Do $iPlasma += 256 Until $iPlasma > -1 EndIf ;Set Pixel Color value from Pallete $aPixels[$iIndex] = $aWorkPallete[$iPlasma] ;Increment Pixel Index Counter $iIndex += 1 If $iIndex = $iGridSize Then $iIndex = 0 Next Next ;Pallete Shift Logic If $bPalleteShift Then $iPalleteShift += $iPalletShiftDirection If $iPalleteShift >= 256 Then $iPalleteShift = 0 If $iPalleteShift <= -1 Then $iPalleteShift = 255 EndIf Return $aPixels EndFunc ;==>_RenderPlasma Func _WM_GETMINMAXINFO($hwnd, $Msg, $wParam, $lParam) ;Only Control Size of Main GUI If $hwnd <> $aGUI[$hGUI] Then Return Default $tagMaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam) DllStructSetData($tagMaxinfo, 7, $iWinMinWidth) ; min X DllStructSetData($tagMaxinfo, 8, $iWinMinHeight) ; min Y Return 0 EndFunc ;==>_WM_GETMINMAXINFO Func _WM_NOTIFY($hwnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") ;Local $tInfo If Not _IsPressed("01", $hDLL) Then Return Default Switch $iIDFrom Case $aGUIPallete[$idSliderRPosition] Switch $iCode Case $NM_CUSTOMDRAW _GUIPallete_ColorSet(0, -1, GUICtrlRead($iIDFrom)) EndSwitch Return 0 Case $aGUIPallete[$idSliderRValue] Switch $iCode Case $NM_CUSTOMDRAW _GUIPallete_ColorSet(0, GUICtrlRead($iIDFrom)) EndSwitch Return 0 Case $aGUIPallete[$idSliderRSpread] Switch $iCode Case $NM_CUSTOMDRAW _GUIPallete_ColorSet(0, -1, "", GUICtrlRead($iIDFrom)) EndSwitch Return 0 Case $aGUIPallete[$idSliderGPosition] Switch $iCode Case $NM_CUSTOMDRAW _GUIPallete_ColorSet(1, -1, GUICtrlRead($iIDFrom)) EndSwitch Return 0 Case $aGUIPallete[$idSliderGValue] Switch $iCode Case $NM_CUSTOMDRAW _GUIPallete_ColorSet(1, GUICtrlRead($iIDFrom)) EndSwitch Return 0 Case $aGUIPallete[$idSliderGSpread] Switch $iCode Case $NM_CUSTOMDRAW _GUIPallete_ColorSet(1, -1, "", GUICtrlRead($iIDFrom)) EndSwitch Return 0 Case $aGUIPallete[$idSliderBPosition] Switch $iCode Case $NM_CUSTOMDRAW _GUIPallete_ColorSet(2, -1, GUICtrlRead($iIDFrom)) EndSwitch Return 0 Case $aGUIPallete[$idSliderBValue] Switch $iCode Case $NM_CUSTOMDRAW _GUIPallete_ColorSet(2, GUICtrlRead($iIDFrom)) EndSwitch Return 0 Case $aGUIPallete[$idSliderBSpread] Switch $iCode Case $NM_CUSTOMDRAW _GUIPallete_ColorSet(2, -1, "", GUICtrlRead($iIDFrom)) EndSwitch Return 0 Case $aGUIPlasmaEditor[$idSliderPlasmaSpread] Switch $iCode Case $NM_CUSTOMDRAW $aPlasmas[$iSelectPlasma][1] = 0.2 * GUICtrlRead($iIDFrom) EndSwitch Return 0 Case $aGUIPlasmaEditor[$idSliderPlasmaRotation] Switch $iCode Case $NM_CUSTOMDRAW EndSwitch Return 0 Case $aGUIPlasmaEditor[$idSliderPlasmaPosition] Switch $iCode Case $NM_CUSTOMDRAW $aPlasmas[$iSelectPlasma - 1][2] = GUICtrlRead($iIDFrom) EndSwitch Return 0 EndSwitch Return 0 EndFunc ;==>_WM_NOTIFY Func _Zoom() Local $bPlaying = $bIsPlaying If $bPlaying Then $bIsPlaying = False Local $iCtrlID = @GUI_CtrlId Switch $iCtrlID Case $aGUI[$idMnuOptionsZoomOut] $iCols += 2 $iRows += 2 If $iCols >= 4 * 8 Then $iCols = 4 * 8 If $iRows >= 4 * 8 Then $iRows = 4 * 8 Case $aGUI[$idMnuOptionsZoomIn] $iCols -= 2 $iRows -= 2 If $iCols <= 4 Then $iCols = 4 If $iRows <= 4 Then $iRows = 4 EndSwitch If $bPlaying Then $bIsPlaying = $bPlaying EndFunc ;==>_Zoom #EndRegion - Main GUI Functions #Region - Pallete Mixer GUI Functions Func _GUIPallete_ColorSet($iColor, $iValue = -1, $iPosition = "", $iSpread = "") If $iValue >= 0 Then $aPalleteSettings[$iColor][2] = (128.0 - $iValue) If $iPosition Then $aPalleteSettings[$iColor][0] = (0.25 * $iPosition) If $iSpread Then $aPalleteSettings[$iColor][1] = ($iSpread ^ 2) Return _GUIPallete_Update() EndFunc ;==>_GUIPallete_ColorSet Func _GUIPallete_Draw() ;Draw Color Pallete in Palette Mixer GUI _GDIPlus_GraphicsClear($hBackbufferPallete, 0xFF000000) Local $iX = 0 For $iColor = 1 To 256 Local $dARGB = $aPallete[$iColor - 1] ;Set Brush Color _GDIPlus_BrushSetSolidColor($hBrushPallete, $dARGB) ;Draw Color Bar to Bitmap _GDIPlus_GraphicsFillRect($hBackbufferPallete, $iX, 0, 320 / 256, 40, $hBrushPallete) $iX += (320 / 256) Next ;Write Bitmap to Screen Return _WinAPI_BitBlt($hDCPallete, 8, 8, 320, 40, $hDC_backbufferPallete, 0, 0, $SRCCOPY) ;blit drawn bitmap to GUI EndFunc ;==>_GUIPallete_Draw Func _GUIPallete_Exit() ; Clean up resources GUIDelete() _GDIPlus_BrushDispose($hBrushPallete) _GDIPlus_GraphicsDispose($hBackbufferPallete) _WinAPI_SelectObject($hDCPallete, $DC_objPallete) _WinAPI_DeleteObject($hHBitmapPallete) _WinAPI_ReleaseDC($aGUIPallete[$hGUIPallete], $hDCPallete) Return 1 EndFunc ;==>_GUIPallete_Exit Func _GUIPallete_Hide() Return GUISetState(@SW_HIDE, $aGUIPallete[$hGUIPallete]) EndFunc ;==>_GUIPallete_Hide Func _GUIPallete_Reset() $aPalleteSettings = $aPalleteDefaults GUICtrlSetData($aGUIPallete[$idSliderRPosition], $aPalleteSettings[0][0] / 0.25) GUICtrlSetData($aGUIPallete[$idSliderRValue], 128 - $aPalleteSettings[0][2]) GUICtrlSetData($aGUIPallete[$idSliderRSpread], Sqrt($aPalleteSettings[0][1])) GUICtrlSetData($aGUIPallete[$idSliderGPosition], $aPalleteSettings[1][0] / 0.25) GUICtrlSetData($aGUIPallete[$idSliderGValue], 128 - $aPalleteSettings[1][2]) GUICtrlSetData($aGUIPallete[$idSliderGSpread], Sqrt($aPalleteSettings[1][1])) GUICtrlSetData($aGUIPallete[$idSliderBPosition], $aPalleteSettings[2][0] / 0.25) GUICtrlSetData($aGUIPallete[$idSliderBValue], 128 - $aPalleteSettings[2][2]) GUICtrlSetData($aGUIPallete[$idSliderBSpread], Sqrt($aPalleteSettings[2][1])) Return _GUIPallete_Update() EndFunc ;==>_GUIPallete_Reset Func _GUIPallete_ShiftToggle() ;Toggle Pallete Shift Local $iCtrlState = GUICtrlRead(@GUI_CtrlId) If BitAND($iCtrlState, $GUI_CHECKED) Then ;Disable PalleteShift $bPalleteShift = False GUICtrlSetState(@GUI_CtrlId, $GUI_UNCHECKED) Else ;Enable PalleteShift $bPalleteShift = True GUICtrlSetState(@GUI_CtrlId, $GUI_CHECKED) EndIf EndFunc ;==>_GUIPallete_ShiftToggle Func _GUIPallete_Show() GUISetState(@SW_SHOW, $aGUIPallete[$hGUIPallete]) _GUIPallete_Draw() EndFunc ;==>_GUIPallete_Show Func _GUIPallete_Update() ;Re-Calculate Work Color Pallete For $iStep = 0 To 255 Local $iR = Int($aPalleteSettings[0][2] + ($aPalleteSettings[0][2] * Sin((3.1415 * $iStep / $aPalleteSettings[0][1]) - $aPalleteSettings[0][0]))) Local $iG = Int($aPalleteSettings[1][2] + ($aPalleteSettings[1][2] * Sin((3.1415 * $iStep / $aPalleteSettings[1][1]) - $aPalleteSettings[1][0]))) Local $iB = Int($aPalleteSettings[2][2] + ($aPalleteSettings[2][2] * Sin((3.1415 * $iStep / $aPalleteSettings[2][1]) - $aPalleteSettings[2][0]))) $aPallete[$iStep] = "0xFF" & Hex($iR, 2) & Hex($iG, 2) & Hex($iB, 2) Next Return _GUIPallete_Draw() EndFunc ;==>_GUIPallete_Update #EndRegion - Pallete Mixer GUI Functions #Region - Plasma Editor GUI Functions Func _GUIPlasmaEditor_Hide() GUISetState(@SW_HIDE, $aGUIPlasmaEditor[$hGUIPlasmaEditor]) EndFunc ;==>_GUIPlasmaEditor_Hide Func _GUIPlasmaEditor_PlasmaAddRem() EndFunc ;==>_GUIPlasmaEditor_PlasmaAddRem Func _GUIPlasmaEditor_PlasmaDisplay() Local $sSelection = GUICtrlRead($aGUIPlasmaEditor[$idCmbPlasmaDisplay]) If $sSelection = "All Combined" Then $iDisplayPlasma = 0 Else $iDisplayPlasma = _GUICtrlComboBox_GetCurSel($aGUIPlasmaEditor[$idCmbPlasmaSelector])+1 EndIf Return $iDisplayPlasma EndFunc ;==>_GUIPlasmaEditor_PlasmaDisplay Func _GUIPlasmaEditor_PlasmaSelect() Local $sSelection = GUICtrlRead($aGUIPlasmaEditor[$idCmbPlasmaSelector]) $iSelectPlasma = _GUICtrlComboBox_GetCurSel($aGUIPlasmaEditor[$idCmbPlasmaSelector]) _GUIPlasmaEditor_PlasmaDisplay() Return _GUIPlasmaEditor_PlasmaSettingsLoad($iSelectPlasma) EndFunc ;==>_GUIPlasmaEditor_PlasmaSelect Func _GUIPlasmaEditor_PlasmaSetPosition() EndFunc ;==>_GUIPlasmaEditor_PlasmaSetPosition Func _GUIPlasmaEditor_PlasmaSetRotation() EndFunc ;==>_GUIPlasmaEditor_PlasmaSetRotation Func _GUIPlasmaEditor_PlasmaSetShape() $aPlasmas[$iSelectPlasma][0] = _GUICtrlComboBox_GetCurSel($aGUIPlasmaEditor[$idCmbPlasmaShape]) EndFunc ;==>_GUIPlasmaEditor_PlasmaSetShape Func _GUIPlasmaEditor_PlasmaSetSpread() $aPlasmas[$iSelectPlasma][4] = _GUICtrlComboBox_GetCurSel($aGUIPlasmaEditor[$idCmbPlasmaSpread]) EndFunc ;==>_GUIPlasmaEditor_PlasmaSetSpread Func _GUIPlasmaEditor_PlasmaSettingsLoad(ByRef $iPlasma) GUICtrlSetData($aGUIPlasmaEditor[$idSliderPlasmaSpread],$aPlasmas[$iPlasma][1]/0.2) _GUICtrlComboBox_SetCurSel($aGUIPlasmaEditor[$idCmbPlasmaShape],$aPlasmas[$iPlasma][0]) If $aPlasmas[$iPlasma][4] Then _GUICtrlComboBox_SetCurSel($aGUIPlasmaEditor[$idCmbPlasmaSpread],1) Else _GUICtrlComboBox_SetCurSel($aGUIPlasmaEditor[$idCmbPlasmaSpread],0) EndIf Return 1 EndFunc ;==>_GUIPlasmaEditor_PlasmaSettingsLoad Func _GUIPlasmaEditor_Show() GUISetState(@SW_SHOW, $aGUIPlasmaEditor[$hGUIPlasmaEditor]) EndFunc ;==>_GUIPlasmaEditor_Show #EndRegion - Plasma Editor GUI Functions edit: Minor tweaks
    • timmalos
      By timmalos
      Hey all.
      I'm trying to know when my user clicks on a Rect drawn via GDI+. Everything is almost working except I have a strange behaviour in the "order" clicks are fired.
      I created a simplified code to help :
      #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <WinAPI.au3> #include <Array.au3> Opt("GUIOnEventMode", 1) ;0=disabled, 1=OnEvent mode enabled _GDIPlus_Startup() Global $hGUI, $hGraphics Global $iWidth = 1024, $iHeight = 762 createGUI() draw() While 1 Sleep(10) WEnd Func createGUI() $hGUI = GUICreate("Current CasparCG Output", $iWidth,$iHeight) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") GUISetBkColor(0x000000) GUISetState(@SW_SHOW) $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing) EndFunc ;==>Example Func draw() ;_WinAPI_draw($hGUI,"","",BitOR($RDW_ERASE,$RDW_INVALIDATE,$RDW_UPDATENOW)) _GDIPlus_GraphicsClear($hGraphics) $hFamily = _GDIPlus_FontFamilyCreate("Arial") $hFont = _GDIPlus_FontCreate($hFamily, 15, 1) $hPen = _GDIPlus_PenCreate(0xFFFEDCFF, 2) ;color format AARRGGBB (hex) $hFormat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($hFormat, 1) _GDIPlus_StringFormatSetLineAlign($hFormat, 1) $hBrushString = _GDIPlus_BrushCreateSolid(0xFFFFFFFF) Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFFF00FF) ;color format AARRGGBB (hex) For $i = 1 to 2 Local $x = 0.25 Local $y = 0.25 Local $w = 0.5 Local $h = 0.5 Local $title = "Layer "&$i If $x >= -1 And $x <= 1 Then $x *= $iWidth If $y >= -1 And $y <= 1 Then $y *= $iHeight If $w >= -1 And $w <= 1 Then $w *= $iWidth If $h >= -1 And $h <= 1 Then $h *= $iHeight $hItem = GUICtrlCreateLabel("", $x,$y,$w,$h) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetOnEvent($hItem,"_gui_layer_clicked") ConsoleWrite("Created label with handle="&$hItem&" $i= " & $i&@CRLF) _GDIPlus_GraphicsFillRect($hGraphics, $x, $y, $w, $h,$hBrush) _GDIPlus_GraphicsDrawRect($hGraphics, $x, $y, $w, $h,$hPen) $tLayout = _GDIPlus_RectFCreate($x, $y, $w, $h) $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $title, $hFont, $tLayout, $hFormat) _GDIPlus_GraphicsDrawStringEx($hGraphics, $title, $hFont, $aInfo[0], $hFormat, $hBrushString) Next _GDIPlus_BrushDispose($hBrush) _GDIPlus_PenDispose($hPen) _GDIPlus_FontDispose($hFont) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_BrushDispose($hBrushString) Return 1 EndFunc Func _gui_layer_clicked() ConsoleWrite("Clicked on " & @GUI_CtrlId&@CRLF) EndFunc Func SpecialEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE ; Clean up resources _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() Exit EndSelect EndFunc ;==>SpecialEvents What happens there :
      We have two rectangles, with the one labelled "2" is front and, the one labelled "1" in background. However when we click, the fired label is the one created first (in the background) and not the second one (in the front).
      Is it normal ?
      If yes, is there any way to change this order ? If I create another label after a first one on the same coords, I would the second one to be fired instead of the first one (This is a simplified code I can't just invert the label order creation easily)
       
      Thanks for your help
       
    • InunoTaishou
      By InunoTaishou
      Struggling a bit to get this GDI+ function converted to AutoIt.
      #include <GDIPlus.au3> _GDIPlus_Startup() Global $hImage = _GDIPlus_ImageLoadFromFile("F:\DCIM\Camera\20170515_111804.jpg") Global $tBufferSize = DllStructCreate("uint") Global $tProperties = DllStructCreate("uint") _GDIPlus_GetPropertySize($hImage, $tBufferSize, $tProperties) Global $tAllItems = DllStructCreate("struct;char[" & DllStructGetData($tBufferSize, 1) & "];endstruct") _GDIPlus_GetAllPropertyItems($hImage, $tBufferSize, $tProperties, $tPropertyItem) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() Func _GDIPlus_GetAllPropertyItems(ByRef $hImage, Const $tTotalBufferSize, Const $tNumProperties, ByRef $tAllItems) If (Not IsDllStruct($tPropertyItem)) Then Return SetError(-1, 0, "") Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetAllPropertyItems", "hwnd", $hImage, "unit", DllStructGetData($tTotalBufferSize, 1), "uint", DllStructGetData($tNumProperties, 1), "ptr", DllStructGetPtr($tAllItems)) If (@error) Then Return SetError(@error, @extended, ConsoleWrite("@Error = " & @error & @LF)) If ($aResult[0]) Then Return SetError($aResult[0], @extended, "") Return $aResult[0] EndFunc ;==>_GDIPlus_GetAllPropertyItems Func _GDIPlus_GetPropertySize(Const ByRef $hImage, ByRef $tTotalBufferSize, ByRef $tNumProperties) If (Not IsDllStruct($tTotalBufferSize)) Then Return SetError(-1, 0, "") If (Not IsDllStruct($tNumProperties)) Then Return SetError(-2, 0, "") Local $aResult = DllCall($__g_hGDIPDll, "uint", "GdipGetPropertySize", "hwnd", $hImage, "uint_ptr", DllStructGetPtr($tTotalBufferSize), "uint_ptr", DllStructGetPtr($tNumProperties)) If (@error) Then Return SetError(@error, @extended, "") If ($aResult[0]) Then Return SetError($aResult[0], 0, "") Return $aResult[0] EndFunc ;==>_GDIPlus_GetPropertySize Got the GetPropertySize function to work, gives me the correct buffer size and the property count, but I cannot figure out how to get the struct for the all items.
      Function on MSDN:
      https://msdn.microsoft.com/en-us/library/windows/desktop/ms535372(v=vs.85).aspx
      Struct needed:
      PropertyItem class:
      https://msdn.microsoft.com/en-us/library/windows/desktop/ms534493(v=vs.85).aspx
      Found other topics about this function in other languages where they used a blank string as the buffer, so I tried using a char array, which doesn't work. Just cannot figure out how to create the struct buffer to hold the data.
    • seangriffin
      By seangriffin
      This is my first release of Box2D for AutoIT.  A very fun and exciting UDF to be bringing to you all.  For those who don't know, Box2D is a physics engine (see http://box2d.org/).  It simulates physical systems using rigid bodies and collision detection.  It is arguably the most prevalent physics engine in existence, within popular physics-based games like Angry Birds using it, and is also at the core of other advanced physics engines such as Unity.
      For a quick demonstration of this UDF in action see the following YouTube video ->  https://youtu.be/h5QH1O63Wik
      Or play "Angry Nerds", the demo game, for yourself.  Visit the EXAMPLES section below.
      Box2D is purely a mathematical engine.  It can model physics numerically.  This in itself is quite interesting, however it really shines when applied to a good graphics engine.  Recently I posted my SFML UDF over here ...
      After benchmarking several popular graphics engines (i.e. GDI+, Direct2D, Irrlicht and SFML) with this Box2D UDF I've selected SFML as my favourite, and the engine that I believe performs the best (fastest) with a rich set of functions appropriate for any physics engine.  With Box2D married with SFML, and running on AutoIT, the results are stunning.
      A HUGE THANK-YOU to jRowe and linus (for the Irrlicht UDF) and UEZ for his post on GDI+ loading screens and trancexx and Eukalyptus for their work on Direct2D.  Without their talents I would not have been able to reach this point on my own.
      The Box2D library is available for C++.  Way back in 2010 it was ported to Pure C by "Paril" and made available on Google Code and known as "Box2C".  Google Code has since been shut down but the but the archive of Box2C still exists to this day here -> https://code.google.com/archive/p/box2c.  This is the library which I have ported to AutoIT in this UDF.
      SFML I am also porting to AutoIT under a separate UDF, as linked above.
      Building this UDF has been a dream come true.  I've been fascinated by physics-based games as far back as the golden age of gaming in the 80's, with thrust style games like Asteroids and platformers like Donkey Kong.  I admired game developers like Jeremy Smith who created what may have been the first true game physics engines for the home computers.  I was astonished by their talents in games like Thrust and Exile for the C64.  Over the years I've attempted to mimic at least some of their success in my own games but alas I can not match their skills.  Now much older automation tools have become my game.  I use them almost every day, AutoIT included.  I've dabbled in other languages for physics game development, like Scratch and Unity, but sadly I had wondered why AutoIT, with all it's glorious capabilities and rapid scripting features, didn't have such a feature.  Hence this UDF.
      This UDF demands a big time investment, and I am time poor, but I have a keen interest in the topic and will do my best to continue it's development.  I am only a hobbyist game developer and welcome comments and suggestions from those far smarter than I on this topic.
      REQUIREMENTS:
      AutoIt3 3.2 or higher LIST OF FUNCTIONS (in progress):
      I've split this UDF into two halves.  "Box2C.au3" is a UDF specifically for Box2C, the C API for Box2D.  It provides the mathematics behind the engine.  Additionally I'm providing "Box2CEx.au3" as an Extension that provides the graphics and gaming functions for Box2D.
      Within the core "Box2C.au3" UDF:
      _Box2C_Startup _Box2C_Shutdown _Box2C_b2Vec2_Constructor _Box2C_b2Vec2_Length _Box2C_b2Vec2_Distance _Box2C_b2World_Constructor _Box2C_b2World_CreateBody _Box2C_b2World_DestroyBody _Box2C_b2World_CreateFixture _Box2C_b2World_CreateFixtureFromShape _Box2C_b2World_Step _Box2C_b2BoxShape_Constructor _Box2C_b2CircleShape_Constructor _Box2C_b2PolygonShape_Constructor _Box2C_b2PolygonShape_Set _Box2C_b2PolygonShape_CrossProductVectorScalar _Box2C_b2PolygonShape_CrossProductVectorVector _Box2C_b2PolygonShape_Normalize _Box2C_b2PolygonShape_ComputeCentroid _Box2C_b2BodyDef_Constructor _Box2C_b2Body_DestroyFixture _Box2C_b2Body_GetPosition _Box2C_b2Body_SetPosition _Box2C_b2Body_GetAngle _Box2C_b2Body_SetAngle _Box2C_b2Body_SetAwake _Box2C_b2Body_SetTransform _Box2C_b2Body_GetLinearVelocity _Box2C_b2Body_SetLinearVelocity _Box2C_b2Body_GetAngularVelocity _Box2C_b2Body_SetAngularVelocity _Box2C_b2Body_ApplyForce _Box2C_b2Body_ApplyForceAtBody _Box2C_b2Body_ApplyDirectionalForceAtBody _Box2C_b2Body_ApplyTorque _Box2C_b2Fixture_GetShape _Box2C_b2Fixture_GetDensity _Box2C_b2Fixture_SetDensity _Box2C_b2Fixture_GetRestitution _Box2C_b2Fixture_SetRestitution _Box2C_b2Fixture_GetFriction _Box2C_b2Fixture_SetFriction _Box2C_b2Fixture_SetSensor Within y "Box2CEx.au3" extension:
      x_metres_to_gui_x y_metres_to_gui_y metres_to_pixels atan2 radians_to_degrees degrees_to_radians _Box2C_Setup_SFML _Box2C_b2Vec2_GetGUIPosition _Box2C_b2World_Setup _Box2C_b2World_GDIPlusSetup _Box2C_b2World_SetPixelsPerMetre _Box2C_b2World_SetGUIArea _Box2C_b2World_GetGUIArea _Box2C_b2World_GetGUIAreaCenter _Box2C_b2World_Create _Box2C_b2World_Step_Ex _Box2C_b2World_StartAnimation _Box2C_b2World_Animate_SFML _Box2C_b2World_Animate_GDIPlus _Box2C_b2World_WaitForAnimateEnd _Box2C_b2ShapeArray_AddItem_SFML _Box2C_b2ShapeArray_SetItem_SFML _Box2C_b2ShapeArray_GetItemImagePath_SFML _Box2C_b2PolygonShape_ArrayAdd_Irrlicht _Box2C_b2PolygonShape_ArrayAdd_GDIPlus _Box2C_b2BodyDefArray_AddItem _Box2C_b2FixtureArray_SetItemSensor _Box2C_b2FixtureArray_GetItemDensity _Box2C_b2FixtureArray_SetItemDensity _Box2C_b2FixtureArray_GetItemRestitution _Box2C_b2FixtureArray_SetItemRestitution _Box2C_b2FixtureArray_GetItemFriction _Box2C_b2FixtureArray_SetItemFriction _Box2C_b2BodyArray_AddItem_SFML _Box2C_b2Body_ArrayAdd_Irrlicht _Box2C_b2Body_ArrayAdd_GDIPlus _Box2C_b2BodyArray_GetItemCount _Box2C_b2BodyArray_GetItemPosition _Box2C_b2BodyArray_SetItemPosition _Box2C_b2BodyArray_GetItemAngle _Box2C_b2BodyArray_SetItemAngle _Box2C_b2BodyArray_GetItemLinearVelocity _Box2C_b2BodyArray_SetItemActive _Box2C_b2BodyArray_SetItemAwake _Box2C_b2BodyArray_SetItemImage_SFML _Box2C_b2BodyArray_SetItemDraw _Box2C_b2BodyArray_ApplyItemForceAtBody _Box2C_b2BodyArray_ApplyItemDirectionalForceAtBody _Box2C_b2BodyArray_Transform_SFML _Box2C_b2Body_Transform_GDIPlus _Box2C_b2BodyArray_Draw_SFML _Box2C_b2Body_ArrayDrawDisplay_SFML _Box2C_b2Body_Destroy _Box2C_b2Body_Destroy_SFML _Box2C_b2Body_Rotate_GDIPlus The SFML functions used in the tests and demos will be available in the SFML UDF post (see reference above).
      EXAMPLES:
      For such a powerful physics engine coupled to such a powerful graphics engine (SFML) it's sad that I've only had time to build one functional game, thus far.  But it's a start.
      My self-titled "Angry Nerds" is merely a demo of the same game concept as the ever-so-popular Angry Birds game.  Angry Birds itself is built on top of Box2D.  Likewise Angry Nerds.  AutoIT + Box2D + SFML to be exact.  I've compiled Angry Nerds and provided an installer also, so you can quickly run the demo for yourself.  From the Github site below (in the DOWNLOAD section) run "Box2C_Angry_Nerds_Game_SFML_installer.exe" to install the demo to a location on your computer (desktop by default).  Go into this folder and run "Box2C_Angry_Nerds_Game_SFML.exe".  All instructions are displayed in-game.  Should be quite easy to work out.
      Aside from Angry Nerds there are also two test scripts:
      Box2C_linear_forces_test_SFML.au3 Box2C_angular_forces_test_SFML.au3 Feel free to run these for a basic demonstration of rigid bodies, forces and collisions.  The heart of Box2D and any physics engine.
      Lastly I also have four speed tests as follows:
      Box2C_speed_test_SFML.au3 Box2C_speed_test_Irrlicht.au3 Box2C_speed_test_D2D.au3 Box2C_speed_test_GDIPlus.au3 These were my initial evaluations into a suitable graphics engine for Box2D.  I've since settled on SFML, but feel free to execute these.  Note they may become quick defective over time as the SFML functions slowly take over.
      DOWNLOADS:
      You can download this UDF, including the examples above and associated files, from the following GitHub page:
      https://github.com/seanhaydongriffin/Box2C-UDF
      Hope you all enjoy!  I certainly am :-)
      Cheers,
      Sean.