Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Christmas Screen Saver (Hardware Accelerated)
#1
My first real attempt playing with hardware acceleration, Let me know your thoughts, anything I missed?

Rename the .exe to .scr and move the single file (everything is embedded) to the windows/system32 folder for a windows screen saver.

Every minute the snow plow runs!!!

Zip file contains all resources.

Code: (Select All)

_Title "Christmas 25 Screen Saver by David Coterel"
$ExeIcon:'.\icon.ico'
Option _Explicit

_FullScreen: Randomize Timer: _Resize On: _MouseHide
Dim spl2, total, limit, c, e, i, d, spt, spl, spd, splight, fps, mx, my As Integer
Dim sl As Single

total = 2800: limit = 120: sl = 1081: spl2 = -281: e = 1

Dim s(total, 3) As Single
Dim gift(10, 4)
Dim Snow32(5) As Long
Dim HWSprite As Long
Dim bg As Long
Dim bg32 As Long
Dim li(57, 2)
Dim bli(99, 2)
Dim cgift32(10) As Long
Dim blsprite As Long
Dim blsprite32(4) As Long
Dim splow1, splow1l, splow2, splow2l, dplol, dplor, cgift, clo As Long


Data 72,497,155,505,222,490,286,473,363,513,297,438,242,431,135,409,81,428,120,351,222,370,288,345,352,366
Data 161,283,162,187,224,237,227,299,283,274,329,246,362,315,237,122,179,131,285,137,223,185,295,203,172,232
Data 321,386,398,412,175,458,185,341,315,326,259,228,199,246,231,268,255,297,192,298,261,514,120,496,88,519
Data 241,148,202,155,261,171,239,203,188,212,128,271,148,360,86,368,252,321,241,387,353,398,280,406,239,463
Data 280,505,392,525,198,412,139,310
For i = 1 To 56: Read li(i, 1), li(i, 2): Next i
Const w& = _RGB32(255)
Const b& = _RGB32(0)
Const dg& = _RGB32(0, 0, 25, 100)

Data 13,530,15,510,15,490,18,470,17,450,13,430,20,410,13,390,12,370,13,350,20,330,16,310,12,290,13,270
Data 17,250,11,230,12,210,20,190,11,170,17,150,15,130,13,110,20,90,15,70,16,50,18,30,18,10
Data 40,15,60,16,80,18,100,19,120,19,140,14,160,16,180,16,200,13,220,17,240,14,260,18,280,19,300,15,320,20
Data 340,16,360,11,380,18,400,13,420,17,440,18,460,11,480,14,500,14,520,16,540,20,560,15,580,14,600,11,620,12
Data 640,20,660,15,680,11,700,16,720,14,740,15,760,15,780,16,800,17,820,16,840,18,860,20,880,18,900,11,920,20,940,16
Data 950,10,948,30,948,50,942,70,942,90,945,110,941,130,941,150,948,170,944,190,941,210,948,230,945,250,949,270
Data 941,290,944,310,950,330,945,350,949,370,949,390,943,410,948,430,950,450,948,470,947,490,947,510
For i = 1 To 99: Read bli(i, 1), bli(i, 2): bli(i, 1) = bli(i, 1) * 2: bli(i, 2) = bli(i, 2) * 2
    If i < 28 Then bli(i, 1) = bli(i, 1) - 20: bli(i, 2) = bli(i, 2) - 20
    If i > 27 And i < 74 Then bli(i, 1) = bli(i, 1) - 25: bli(i, 2) = bli(i, 2) - 25
    If i > 73 Then bli(i, 1) = bli(i, 1) - 20: bli(i, 2) = bli(i, 2) + 20
Next i

HWSprite = _NewImage(13, 13, 32)
blsprite = _NewImage(40, 40, 32)

_Dest blsprite
Color _RGB32(0, 0, 0, 0), _RGB32(0, 0, 0, 0): Cls
Circle (20, 20), 15, b&: Circle (20, 20), 14, b&
Paint (20, 20), _RGB32(255, 0, 0), b&
blsprite32(1) = _CopyImage(blsprite, 33)
Paint (20, 20), _RGB32(0, 255, 0), b&
blsprite32(2) = _CopyImage(blsprite, 33)
Paint (20, 20), _RGB32(0, 0, 255), b&
blsprite32(3) = _CopyImage(blsprite, 33)
Paint (20, 20), _RGB32(255, 255, 0), b&
blsprite32(4) = _CopyImage(blsprite, 33)
_FreeImage blsprite

For c = 1 To total
    s(c, 1) = Rnd * 1920: s(c, 2) = Rnd * 1080
    s(c, 3) = 1 + Rnd * 1.5
Next c

For c = 1 To 10
    gift(c, 1) = Rnd * 1734 + 50: gift(c, 2) = Rnd * 944 + 50
    gift(c, 3) = -.5 + (.25 + Rnd * .75): gift(c, 4) = -.5 + (.25 + Rnd * .75)
Next c

_Dest HWSprite
For c = 0 To 5
    Color _RGB32(0, 0, 0, 20), _RGB32(0, 0, 0, 0): Cls
    Circle (6, 6), c + 1, w&
    Paint (6, 6), w&, w&
    Snow32(c) = _CopyImage(HWSprite, 33)
Next c: _FreeImage HWSprite


$Embed:'.\dslplowlr.ogg','dplowl'
$Embed:'.\dslplowrl.ogg','dplowr'
$Embed:'.\bgss.png','bg'
$Embed:'.\splow.png','spl'
$Embed:'.\splow1.png','spl1'
$Embed:'.\splowl.png','spll'
$Embed:'.\splowl1.png','spll1'
$Embed:'.\orn1.png','or1'
$Embed:'.\orn2.png','or2'
$Embed:'.\orn3.png','or3'
$Embed:'.\orn4.png','or4'
$Embed:'.\orn5.png','or5'
$Embed:'.\orn6.png','or6'
$Embed:'.\orn7.png','or7'
$Embed:'.\orn8.png','or8'
$Embed:'.\orn9.png','cg'
$Embed:'.\orn10.png','cg2'
$Embed:'.\cloop.ogg','cloop'

splow1 = _LoadImage(_Embedded$("spl"), 32, "memory")
splow1l = _LoadImage(_Embedded$("spl1"), 32, "memory")
splow2 = _LoadImage(_Embedded$("spll"), 32, "memory")
splow2l = _LoadImage(_Embedded$("spll1"), 32, "memory")

dplol = _SndOpen(_Embedded$("dplowl"), "memory"): _SndVol dplol, .4
dplor = _SndOpen(_Embedded$("dplowr"), "memory"): _SndVol dplor, .4
clo = _SndOpen(_Embedded$("cloop"), "memory"): _SndVol clo, .2
bg = _LoadImage(_Embedded$("bg"), 32, "memory")

_SndLoop clo

cgift = _LoadImage(_Embedded$("cg"), 32, "memory")
cgift32(1) = _CopyImage(cgift, 33): _FreeImage cgift
cgift = _LoadImage(_Embedded$("cg2"), 32, "memory")
cgift32(2) = _CopyImage(cgift, 33): _FreeImage cgift
cgift = _LoadImage(_Embedded$("or1"), 32, "memory")
cgift32(3) = _CopyImage(cgift, 33): _FreeImage cgift
cgift = _LoadImage(_Embedded$("or2"), 32, "memory")
cgift32(4) = _CopyImage(cgift, 33): _FreeImage cgift
cgift = _LoadImage(_Embedded$("or3"), 32, "memory")
cgift32(5) = _CopyImage(cgift, 33): _FreeImage cgift
cgift = _LoadImage(_Embedded$("or4"), 32, "memory")
cgift32(6) = _CopyImage(cgift, 33): _FreeImage cgift
cgift = _LoadImage(_Embedded$("or5"), 32, "memory")
cgift32(7) = _CopyImage(cgift, 33): _FreeImage cgift
cgift = _LoadImage(_Embedded$("or6"), 32, "memory")
cgift32(8) = _CopyImage(cgift, 33): _FreeImage cgift
cgift = _LoadImage(_Embedded$("or7"), 32, "memory")
cgift32(9) = _CopyImage(cgift, 33): _FreeImage cgift
cgift = _LoadImage(_Embedded$("or8"), 32, "memory")
cgift32(10) = _CopyImage(cgift, 33): _FreeImage cgift

_Dest bg: Screen _NewImage(1920, 1080, 32): bg32 = _CopyImage(bg, 33): _DisplayOrder _Hardware , _Software

Do
    _Limit limit
    _Dest 0: _DontBlend
    _PutImage (0, 0), bg32

    d = e: c = 0: For i = 1 To 99: c = c + 1: d = d + 1: If d = 5 Then d = 1
        _PutImage (bli(i, 1), bli(i, 2)), blsprite32(d)
    Next i
    c = e: For i = 1 To 56: c = c + 1: If c = 5 Then c = 1
        _PutImage (li(i, 1) * 2, li(i, 2) * 2)-(li(i, 1) * 2 + 15, li(i, 2) * 2 + 15), blsprite32(c)
    Next i
    For c = 1 To 10: _PutImage (gift(c, 1), gift(c, 2)), cgift32(c)
        gift(c, 1) = gift(c, 1) + gift(c, 3): gift(c, 2) = gift(c, 2) + gift(c, 4)
        gift(c, 1) = gift(c, 1) + gift(c, 3)
        gift(c, 2) = gift(c, 2) + gift(c, 4)
        If gift(c, 1) > 1784 Or gift(c, 1) < 50 Then gift(c, 3) = -1 * gift(c, 3)
        If gift(c, 2) > 994 Or gift(c, 2) < 50 Then gift(c, 4) = gift(c, 4) * -1
    Next c
    d = 0: For c = 1 To total: _PutImage (s(c, 1), s(c, 2)), Snow32(d): d = d + 1: If d = 6 Then d = 0
        s(c, 2) = s(c, 2) + s(c, 3): If s(c, 2) > sl Then Circle (s(c, 1), s(c, 2)), 2 + Rnd * 2, w&: s(c, 2) = -10: s(c, 1) = Rnd * 1920
    Next c

    spt = spt + 1: If spt > 7200 Then spl = 1: spt = 0: sl = 1081: If spd = 0 Then _SndPlay dplol Else _SndPlay dplor
    If spl = 1 Then
        If splight = 0 Then
            If spd = 0 Then _PutImage (spl2, 977), splow1: _PutImage (spl2 + 1, 977), splow1: spl2 = spl2 + 2: If spl2 > 1921 Then spl = 0: spd = 1
            If spd = 1 Then _PutImage (spl2, 977), splow1l: _PutImage (spl2 + 1, 977), splow1l: spl2 = spl2 - 2: If spl2 < -281 Then spl = 0: spd = 0
        Else
            If spd = 0 Then _PutImage (spl2, 977), splow2: _PutImage (spl2 + 1, 977), splow2: spl2 = spl2 + 2: If spl2 > 1921 Then spl = 0: spd = 1
            If spd = 1 Then _PutImage (spl2, 977), splow2l: _PutImage (spl2 + 1, 977), splow2l: spl2 = spl2 - 2: If spl2 < -281 Then spl = 0: spd = 0
        End If
    End If

    fps = fps + 1: If fps = limit Then fps = 0: sl = sl - .45: e = e + 1: If e = 5 Then e = 1
    If fps Mod 30 = 0 Then splight = 1 - splight

    _Display

    Do While _MouseInput 'check for mouse movement
        mx = mx + _MouseMovementX
        my = my + _MouseMovementY
    Loop

Loop Until InKey$ > "" Or mx <> 0 Or my <> 0
_SndStop clo
_SndStop dplol
_SndStop dplor
For c = 1 To 5: _FreeImage Snow32(c): Next c
For c = 1 To 4: _FreeImage blsprite32(c): Next c
For c = 1 To 10: _FreeImage cgift32(c): Next c
_FreeImage bg
_FreeImage bg32
_FreeImage splow1
_FreeImage splow1l
_FreeImage splow2
_FreeImage splow2l
_SndClose dplol
_SndClose dplor
_SndClose clo
System


Attached Files
.zip   Christmas Screen Saver.zip (Size: 12.12 MB / Downloads: 32)
Reply
#2
Note that once you rename it to a *.scr file, you can then right click on that SCR and install it if you want and add it to the list of system screen savers.

(Unless one of the latest updates/changes to windows has broken that functionality.  It's been that way since back in the days of XP forward though, so right-click and install from that context window should work.  *I think.* )
Reply
#3
+1 luv the snowplow and music with this, nice effort!
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Demo: Adaptable Hardware Grid Pete 1 182 02-01-2026, 08:16 PM
Last Post: grymmjack
  Why Pete Likes Hardware Acceleration - Popup Demo Pete 6 598 11-26-2025, 09:02 PM
Last Post: Pete
  Super Plasmas screen saver Dav 15 1,213 11-13-2025, 12:42 PM
Last Post: Dav
  Merry Christmas Globes! SierraKen 10 1,974 12-20-2024, 03:46 AM
Last Post: SierraKen
  aquascape screen saver ver1.1 kn0ne 0 566 04-23-2024, 10:20 PM
Last Post: kn0ne

Forum Jump:


Users browsing this thread: 1 Guest(s)