Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A Screensaver
#1
I guess this would be a screensaver.  As you guys can probably guess from some of the code that I've been sharing over the last few days, I've just been playing around at tossing different things at a program and seeing what sticks.  I'm not really doing anything by goofing off, but I guess this would be similar to the Windows Mystify Screensaver, if anyone is interested in it.

Code: (Select All)
Screen _NewImage(800, 600, 32)
_FullScreen
Dim x1, y1, x2, y2 As Integer
Dim dx1, dy1, dx2, dy2 As Integer
Dim r, g, b As Integer

' Initialize coordinates and directions
x1 = Int(Rnd * 800): y1 = Int(Rnd * 600)
x2 = Int(Rnd * 800): y2 = Int(Rnd * 600)
dx1 = 5: dy1 = 8: dx2 = -5: dy2 = -8

Do
r = Int(Rnd * 256): g = Int(Rnd * 256): b = Int(Rnd * 256): a = Int(Rnd * 256)
Line (x1, y1)-(x2, y2), _RGBA32(r, g, b, a)

' Update coordinates
x1 = x1 + dx1: y1 = y1 + dy1: x2 = x2 + dx2: y2 = y2 + dy2

' Bounce off the edges of the screen
If x1 <= 0 Or x1 >= 800 Then dx1 = -dx1
If y1 <= 0 Or y1 >= 600 Then dy1 = -dy1
If x2 <= 0 Or x2 >= 800 Then dx2 = -dx2
If y2 <= 0 Or y2 >= 600 Then dy2 = -dy2
Line (0, 0)-(_Width, _Height), &H10000020&&, BF
_Display
_Limit 60
Loop Until InKey$ <> ""
System



It might need a few more lines to it to be a better replica, but it certainly seems to be on the right track to being something similar.  Feel free to play with it and modify it as wanted for your own enjoyment.  Wink
Reply
#2
Classic, and you can play that one right from the browser:
Reply
#3
And you can see a more realistic Mystify as my first post in Screen savers.
https://qb64phoenix.com/forum/showthread...898#pid898
b = b + ...
Reply
#4
Wow Mark, that's really cool! +2!

Pete Wink
Reply
#5
An updated version which I guess I'd call a simple "Dancing Triangle":

Code: (Select All)
Screen _NewImage(800, 600, 32)
_FullScreen
Dim x1, y1, x2, y2, x3, y3
Dim dx1, dy1, dx2, dy2, dx3, dy3
Dim r, g, b As Integer

' Initialize coordinates and directions
x1 = Int(Rnd * 800): y1 = Int(Rnd * 600)
x2 = Int(Rnd * 800): y2 = Int(Rnd * 600)
x3 = Int(Rnd * 800): y3 = Int(Rnd * 600)
dx1 = 5: dy1 = 8: dx2 = -5: dy2 = -8: dx3 = 2: dy3 = 3

Do
    r = Int(Rnd * 256): g = Int(Rnd * 256): b = Int(Rnd * 256): a = Int(Rnd * 256)
    Line (x1, y1)-(x2, y2), _RGBA32(r, g, b, a)
    Line -(x3, y3), _RGBA(r, g, b, a)
    Line -(x1, y1), _RGBA(r, g, b, a)

    ' Update coordinates
    x1 = x1 + dx1: y1 = y1 + dy1: x2 = x2 + dx2: y2 = y2 + dy2: x3 = x3 + dx3: y3 = y3 + dy3

    ' Bounce off the edges of the screen
    If x1 <= 0 Or x1 >= 800 Then dx1 = -dx1
    If y1 <= 0 Or y1 >= 600 Then dy1 = -dy1
    If x2 <= 0 Or x2 >= 800 Then dx2 = -dx2
    If y2 <= 0 Or y2 >= 600 Then dy2 = -dy2
    If x3 <= 0 Or x3 >= 800 Then dx3 = -dx3
    If y3 <= 0 Or y3 >= 600 Then dy3 = -dy3

    Line (0, 0)-(_Width, _Height), &H10000020&&, BF
    _Display
    _Limit 60
Loop Until InKey$ <> ""
System

For just goofing and wasting time, that's not an overall bad effect for such simple little code.  Smile
Reply
#6
I think you made a minor goof on this line...

Dim x1, y1, x2, y2, x3, y2 As Integer 

You don't need two types of y2.

-1 (Just kidding!)

Pete Big Grin
Reply
#7
I don't know whatchu talking 'bout, Willis!!

Tongue
Reply
#8
Nice edit, Steve... Urkel!

[Image: d854570a0b893bf2fadb65f81b63159b.jpg]

Pete Big Grin
Reply
#9
You got the wrong reference.  Big Grin

Reply
#10
I've seen both shows. Unfortunately, there was no funny retort associated with Colman's show, so I outsourced to another network, and used a character from Family Matters, Steve Urkel.

Pete Big Grin
Reply




Users browsing this thread: 18 Guest(s)