Jump to content

Target Screensaver


crashdemons
 Share

Recommended Posts

I made this particular GDI+ screensaver to resemble the credits of either a movie or a video game with something similar. - Once I remember which one, I will post it here.

In the credits, a target would drift across the screen for a while, lock-on to a point, and move mechanically towards it - once it reached it, a portion of the credits was displayed there.

Posted Image

NOTE: This screensaver is very simple - but enjoyable on some level.

This screensaver consists of a target that floats on the screen until it "locks-on" to a point in space.

Once it "locks-on" it moves towards the target first on one axis (horizontally) then on the other (vertically) - the way a rail-based machine might.

When it reaches the point it locked onto, it will either determine that it was the correct point or whether it was in error and needs to re-target it's point. (the latter makes it immediately "lock-on" to a new point)

Once it reaches the correct point it will mark it with a "+" and some bogus text and return to floating mode.

The + and the text will fade out before the next "lock-on."

Further Notes:

The target is green while idle and red when "locked-on."

There is no sound in drifting/floating/idle mode.

Fast movement, Slow[ing] movement, Targetting, and the Targetting Errors have sounds.

The sounds are not high-quality as I do not have a recording studio or professional audio editing talent.

The sounds are not necessarily required.

This screensaver supports the screensaver preview window. (when compiled)

Let me know what you think and what you would like to see added to it.

Download Source w/ sounds -

AITargettingSS_v1.5.zip

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.)

Link to comment
Share on other sites

@crashdemons

Nice one :P

This is the installation pack of your scr : Link

Cheers, FireFox.

It doesn't need any installation pack - look at the download link again (1.1).

The current script FileInstalls the WAV files if compiled.

Also, the wrapper settings are there for it to be compiled to SCR by default.

#AutoIt3Wrapper_outfile=AITargetting.scr

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.)

Link to comment
Share on other sites

As far as I can see it has no multi monitor support (currently I cannot test it).

Just look again in my screen saver code how to implement multi monitor support :P

Nice work.

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

As far as I can see it has no multi monitor support (currently I cannot test it).

Just look again in my screen saver code how to implement multi monitor support :P

Nice work.

UEZ

I'll take a look - I don't use and am not around multiple monitors a lot so I didn't even think about it at the time.

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.)

Link to comment
Share on other sites

... multi monitor support ...

Just uploaded 1.2 - should allow multi-monitor displays now.

I saw that your example adds the virtual X-coordinate to the drawing position

- but unless I missed something, the drawing coordinates are relative to the position of the Graphic that you're drawing on.

(eg: 0,0 is always the left-top corner of a GUI's client area, even if the GUI is located at a negative position.)

So, as long as my GUI is at the virtual left edge and is the width of the virtual width, there should not be a problem.

Right?

Edit: typos

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.)

Link to comment
Share on other sites

Just uploaded 1.2 - should allow multi-monitor displays now.

I saw that your example adds the virtual X-coordinate to the drawing position

- but unless I missed something, the drawing coordinates are relative to the position of the Graphic that you're drawing on.

(eg: 0,0 is always the left-top corner of a GUI's client area, even if the GUI is located at a negative position.)

So, as long as my GUI is at the virtual left edge and is the width of the virtual width, there should not be a problem.

Right?

Edit: typos

Looks good! I just connected my LCD monitor to my notebook and it seems to be working properly! Well done...

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

@crashdemons

I've used it as screen saver, it works great :P

Note : when my computer is "off" (black screen with no signal), I come back to the desktop but there is the screen saver and it stay few seconds (even if you move the mouse and tape on keyboard)

Edit : I sometimes get an array dimention exceded error

Cheers, FireFox.

Edited by FireFox
Link to comment
Share on other sites

Haven't been able to replicate those problems - and mines been set as my default SS all night.

Here it exits immediately upon input - However, some computers and settings shut off the hard drive or pause operation when idle - causing a delay upon resume. (just a possibility)

There shouldn't be any array errors - the array sizes don't change and all of the elements are defined.

Could be a quirk in AutoIt... - or something else that is different between 3.2.12.1 and 3.3

I'll revise all of the arrays, but I'm not seeing anything.

What you can do:

Try disabling your other screensavers and running the screensaver from SciTE so that you can catch a specific error line. (and then do whatever you need to get the error to occur)

That'll give me more information than "error!"

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.)

Link to comment
Share on other sites

@crashdemons

Strange...the error occurs only when the screensaver is started automatically as SCR....

Cheers, FireFox.

See if the new update (1.3) fixes it - I tightened my code a little.

Still shouldn't be happening at all. :P

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.)

Link to comment
Share on other sites

The CPU usage is very high. A Sleep(25) in Func Draw($w, $h) will reduce it a bit.

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

The CPU usage is very high. A Sleep(25) in Func Draw($w, $h) will reduce it a bit.

UEZ

NOTE: The Initial and Ending CPU Usage (first and last 1-3 seconds) WILL ALWAYS be higher - however, this is temporary.

:P It's only using 17% CPU consistently here on 1.5Ghz ...

If I add sleep I want to add it to the while loops (see While $new >= $last and the first While 1) where there already is a Sleep(50).

Adding 25ms to that sleep ( Sleep(75) ) only dropped it to 16% here.

If I up the delay to 100ms total, it drops to 13%, but the animation and audio is somewhat noticeably slower.

The question is, what do you consider "very high" ?

---------------------------

You can test the *working* CPU Usage by making these modifications (so that you can see TaskManager and move the Mouse.

Change This:

$w = $w[0]
        $h = $h[0]
...
            $new = _IdleTicks()

To This:

$w = 500;$w[0]
        $h = 500;$h[0]
...
;$new = _IdleTicks()

_IdleTicks() does not seem to use a signficant amount of CPU to make a difference in testing.

Remember to change this back when you're done.

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.)

Link to comment
Share on other sites

I just started your ss and came back after a little talk with a colleague and heard the the CPU fan made noise.

It ran it for 60 seconds and here the CPU monitor:

Ahhh,

I assume it has something to do with my screen resolution:

1920x2224 and thus the _GDIPlus_GraphicsDrawImageRect ($gro, $grb, 0, 0, $w, $h) is causing the high cpu usage!

UEZ

PS: screenshot removed because attachment space is nearly full :-(

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Yes, a larger drawing area increases the size of the graphic object and the buffer.

I'm not sure what to tell you, perhaps I can add a configuration option for 'speed.'

Edit: Would drawing the image smaller and resizing to the screen dimensions help or hurt?

Or maybe I should just force your screen to a new resolution?

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.)

Link to comment
Share on other sites

Yes, a larger drawing area increases the size of the graphic object and the buffer.

I'm not sure what to tell you, perhaps I can add a configuration option for 'speed.'

Edit: Would drawing the image smaller and resizing to the screen dimensions help or hurt?

Or maybe I should just force your screen to a new resolution?

What about to delete only the lines you drew instead of deleting whole screen by overwriting it with black lines?

I got a similar performance problem on my huge screen resolution with my screensaver and I only delete the area where the squares are drawn. It gave me 15% more speed.

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

What about to delete only the lines you drew instead of deleting whole screen by overwriting it with black lines?

I got a similar performance problem on my huge screen resolution with my screensaver and I only delete the area where the squares are drawn. It gave me 15% more speed.

UEZ

Seems to use more CPU than before.

Here:

Func Draw($w, $h)
    ;since the coordinates drawn here are relative to the GUI Created, the upper-left is always 0,0;
    ; no need to worry about virtual coordinates.
    Global $Sounds, $hBrush, $hFormat, $hFont, $tLayout, $hPen, $hPen2, $gr, $gro, $grb
    Global $FastMove, $SlowMove, $SlowestMove
    Global $target, $goto, $XT, $TargetTime, $ifakeout, $ifakeout_max
    Global $point
    Local $line
    Local $k = Int((20 / 768) * $h)
    Local $k2 = Int((5 / 768) * $h)
    Local $x = $target[0]
    Local $y = $target[1]
    Local $thPen = $hPen
    Local $XTDiff = TimerDiff($XT)
    If (Not $goto) And $XTDiff > $TargetTime Then
        $goto = True
        $target[2] = 0
        $target[3] = 0
        ;$ygoto=True
        Local $pointx[2] = [Random($k, $w - $k, 1), Random($k, $h - $k, 1) ]
        $point = $pointx; shouldn't have to do this.
        $TargetTime = Random(5000, 15000, 1)
        $ifakeout = 0
        ConsoleWrite('Target Point (' & $point[0] & ',' & $point[1] & ')' & @CRLF)
        _SoundPlay($Sounds[2], 0)
        _SoundPlay($Sounds[2], 0)
    EndIf
    If $goto Then
        $thPen = $hPen2
        Local $xdiff = $point[0] - $target[0]
        Local $ydiff = $point[1] - $target[1]
        Local $xdiffa = Abs($xdiff)
        Local $ydiffa = Abs($ydiff)
        If $xdiff <> 0 Then
            ConsoleWrite(@TAB & 'Target X ' & $xdiff & @CRLF)
            $target[2] = $xdiff / $xdiffa
            Select
                Case $xdiffa > $FastMove[0]
                    $target[2] *= $FastMove[1]
                    _SoundPlay($Sounds[0], 0)
                Case $xdiffa > $SlowMove[0]
                    $target[2] *= $SlowMove[1]
                    _SoundPlay($Sounds[0], 0)
                Case $xdiffa >= $SlowestMove
                    $target[2] *= $SlowestMove
                    _SoundPlay($Sounds[1], 0)
                Case Else
                    _SoundPlay($Sounds[1], 0)
            EndSelect
        Else
            $target[2] = 0
            If $ydiff <> 0 Then
                ConsoleWrite(@TAB & 'Target Y ' & $ydiff & @CRLF)
                $target[3] = $ydiff / $ydiffa
                Select
                    Case $ydiffa > $FastMove[0]
                        $target[3] *= $FastMove[1]
                        _SoundPlay($Sounds[0], 0)
                    Case $ydiffa > $SlowMove[0]
                        $target[3] *= $SlowMove[1]
                        _SoundPlay($Sounds[0], 0)
                    Case $ydiffa >= $SlowestMove
                        $target[3] *= $SlowestMove
                        _SoundPlay($Sounds[1], 0)
                    Case Else
                        _SoundPlay($Sounds[1], 0)
                EndSelect
            Else
                If $ifakeout < $ifakeout_max And Random(0, 100, 1) < 40 Then; If there hasn't been $ifakeout_max fake-outs, there will be a 40% chance of getting one.
                    $target[2] = 0
                    $target[3] = 0
                    Local $pointx[2] = [Random($k, $w - $k, 1), Random($k, $h - $k, 1) ]
                    $point = $pointx
                    $ifakeout += 1
                    ConsoleWrite('- Target Faked-Out; Point (' & $point[0] & ',' & $point[1] & ')' & @CRLF)
                    _SoundPlay($Sounds[3], 0)
                Else
                    ConsoleWrite('- On Target' & @CRLF)
                    $target[2] = Random($ReguMove[0], $ReguMove[1], 1)
                    $target[3] = Random($ReguMove[0], $ReguMove[1], 1)
                    $goto = False
                    $thPen = $hPen
                    $ptext = '+ 0064089BA72FG'
                    $tLayout = 0
                    $tLayout = _GDIPlus_RectFCreate ($point[0], $point[1], 100, 20)
                    $XT = TimerInit()
                    $ptm = TimerInit()
                    $ifakeout = 0
                    _SoundPlay($Sounds[2], 0)
                EndIf
            EndIf
        EndIf
    EndIf
    
    For $i=0 To 1
    ;_GDIPlus_GraphicsClear ($gr, 0xFF000000)
        _GDIPlus_GraphicsDrawRect ($gr, $x - $k, $y - $k, $k * 2, $k * 2, $thPen);box
        _GDIPlus_GraphicsDrawLine ($gr, $x, 0, $x, $y - $k2, $thPen);top
        _GDIPlus_GraphicsDrawLine ($gr, $x, $y + $k2, $x, $h, $thPen);bottom
        _GDIPlus_GraphicsDrawLine ($gr, 0, $y, $x - $k2, $y, $thPen);left
        _GDIPlus_GraphicsDrawLine ($gr, $x + $k2, $y, $w, $y, $thPen);right
        Local $ptmd = TimerDiff($ptm)
        If $i=0 Then
            If $ptmd < 5000 Then
                $hBrush = _GDIPlus_BrushCreateSolid (0xFF000000 + Floor(((5000 - $ptmd) / 5000) * 0xFF) * 0x10000)
                _GDIPlus_GraphicsDrawStringEx ($gr, $ptext, $hFont, $tLayout, $hFormat, $hBrush)
                _GDIPlus_BrushDispose ($hBrush)
            EndIf
            _GDIPlus_GraphicsDrawImageRect ($gro, $grb, 0, 0, $w, $h);copy to bitmap
            $thPen=0; overwrite black next loop
        Else
            If $ptmd < 5000 Then _GDIPlus_GraphicsFillRect($gr,$point[0],$point[1],100,20)
        EndIf
    Next
    
    
    $target[0] += $target[2]
    $target[1] += $target[3]
    iLimit($target[0], $k, $w - $k)
    If @error Then $target[2] *= -1
    iLimit($target[1], $k, $h - $k)
    If @error Then $target[3] *= -1
EndFunc  ;==>Draw
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.)

Link to comment
Share on other sites

Now it has a better performance according to the task manager!

One mistake from me: of course you need to copy the whole screen (_GDIPlus_GraphicsDrawImageRect ($gro, $grb, 0, 0, $w, $h)) - I meant the

_GDIPlus_GraphicsClear ($gr, 0xFF000000) line of course! Sorry,

UEZ

PS: screenshot removed because attachment space is nearly full :-(

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

I think your TaskManager is broken - it went from 13-17% to 35-40% for me :|

For similar reasons, it looks a lot more jumpy here.

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.)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...