Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
You are now in my power...
#1
You will do as I say....

Code: (Select All)
Screen _NewImage(640, 480, 32)
Dim As Integer x, y, r, g, b
Dim As Single t
Do
t = t + 0.2
For y = -240 To 240
For x = -320 To 320
r = Plasma(x, y, t) ' Red channel
g = Bubbles(x, y, t) ' Green channel
b = Plasma(x, y, t + 2) ' Blue channel
PSet (x + 320, y + 240), _RGB32(r, g, b)
Next x
Next y
_Display
_Limit 60 ' Limit to 60 frames per second
Loop Until InKey$ <> ""
System

Function Bubbles% (x As Single, y As Single, t As Single) ' Function to create bubble effect
Bubbles = 127 + 127 * Sin(Sqr((x - 320 * Sin(t / 5)) ^ 2 + (y - 240 * Cos(t / 7)) ^ 2) / 8 - t)
End Function

Function Plasma% (x As Single, y As Single, t As Single) ' Function to calculate plasma effect
Plasma = 127 + 127 * Sin(Sqr(x * x + y * y) / 8 - t)
End Function

I really don't know what to call the above program. I *was* attempting to create a plasma-like bubble effect, similar to a lava lamp. Instead, I've created one of the most interesting little goofs that I've had the pleasure of creating for a very long time!

Everyone should test this one and see what can be accomplished in only 25 lines of code. Then, after everyone tries it out, the really smart people (which we all know excludes @Pete) should tell me HOW THE HECK??!!
Reply
#2
Brilliant! I have discovered that, if you stare at the centre of the 'rear' pattern for more than 17 minutes, one may never have the need to use glasses again. A seeing eye-dog maybe... but no need for glasses.... Difficult to focus on the keyboard after 14.5 minutes... and pretty much all else... I know my mouse is on the desk somewhere.... I cannot feel my tongue... Nah! kidding. Just brilliant...
May your journey be free of incident. Live long and prosper.
Reply
#3
Pete is busy working on a much bigger AI app. It takes Q and A.

PeteXa...

Q: Where is the smartest person in Virginia?

A: Traveling north on U.S. 301 BACK to Maryland.

Pete Big Grin
Reply
#4
Another interesting glitch which I made trying to rotate a sphere:

Code: (Select All)
_Title "Rotating Sphere in QB64PE"
Screen _NewImage(800, 600, 32)
Dim Shared sphere(360, 360) As _Unsigned Long
Dim Shared rotationX, rotationY As Single

' Initialize the sphere
For phi = 0 To 359
For theta = 0 To 359
x = Cos(_D2R(phi)) * Sin(_D2R(theta))
y = Sin(_D2R(phi)) * Sin(_D2R(theta))
z = Cos(_D2R(theta))
sphere(phi, theta) = _RGB32(Cos(_D2R(phi)) * 127 + 128, Sin(_D2R(phi)) * 127 + 128, z * 127 + 128)
Next
Next

' Main loop
Do
If _KeyDown(18432) Then rotationX = rotationX - 5
If _KeyDown(20480) Then rotationX = rotationX + 5
If _KeyDown(19200) Then rotationY = rotationY - 5
If _KeyDown(19712) Then rotationY = rotationY + 5
Cls , 0
_PrintString (0, 0), "Rotating Rainbow Sphere"
_PrintString (0, 16), "Use arrow keys to rotate"

' Draw the sphere
For phi = 0 To 359 Step .25
For theta = 0 To 359 Step .25
x = Cos(_D2R(phi)) * Sin(_D2R(theta))
y = Sin(_D2R(phi)) * Sin(_D2R(theta))
z = Cos(_D2R(theta))

' Rotate around X axis
y = y * Cos(_D2R(rotationX)) - z * Sin(_D2R(rotationX))
z = y * Sin(_D2R(rotationX)) + z * Cos(_D2R(rotationX))
'y = y1
'z = z1

' Rotate around Y axis
x = x * Cos(_D2R(rotationY)) + z * Sin(_D2R(rotationY))
z = -x * Sin(_D2R(rotationY)) + z * Cos(_D2R(rotationY))
'x = x1
'z = z1

' Project to 2D
screenX = 400 + x * 200
screenY = 300 - y * 200
PSet (screenX, screenY), sphere(phi, theta)
Next
Next

_Display
_Limit 60
Loop Until _KeyDown(27)

You can see the actual working version in the Works in Progress topic, but this one was rather neat as it was a screw up I generated on the way to the other. LOL!

This might could be used to generate a planet going through a black hole or some such, I guess. Big Grin
Reply
#5
Quote:This might could be used to generate a planet going through a black hole or some such, I guess. [Image: biggrin.png]

You'd need a 'Spaghetti Effect' for that, but knowing you, you'd break the effect half-way through.

Pete Big Grin
Reply




Users browsing this thread: 1 Guest(s)