Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
time tunnel animation - can this be done as high res and smooth as the video?
#11
Eye Candy #10 for @madscijr
Code: (Select All)
_Title " Eye Candy #10 B&W" ' b+ 2022-03-09
DefDbl A-Z
xmax = _DesktopWidth: ymax = _DesktopHeight
Screen _NewImage(xmax, ymax, 32)
_ScreenMove 0, 0
xc = xmax / 2
yc = ymax / 2
diag = Sqr(xc * xc + yc * yc)
p2 = _Pi * 2
Dim colr(-100 To diag + 1000) As _Unsigned Long
Dim Shared cN, pR, pG, pB
While 1
    resetPlasma
    For i = -100 To diag + 1000
        colr(i) = Plasma~&
    Next

    ro = 950: s = 0
    While ro > -50 And _KeyDown(27) = 0
        k$ = InKey$
        If Len(k$) Then Exit While
        Cls
        For a = 0 To p2 / 64 Step p2 / (16 * 360)
            i = 50 * Sin(s) ' 2 * s or just s
            For r = 0 To diag
                PSet (xc + r * Cos(a), yc + r * Sin(a)), colr(r + i + ro)
            Next
            s = s + p2 / 180
        Next
        sx1 = xc: sy1 = yc: sx2 = xc + diag * Cos(.002): sy2 = yc + diag * Sin(.002): sx3 = xc + diag * Cos(p2 / 64 - .002): sy3 = yc + diag * Sin(p2 / 64 - .002)
        For a = p2 / 64 To p2 - p2 / 64 Step p2 / 64
            dx1 = xc: dy1 = yc: dx2 = xc + diag * Cos(a): dy2 = yc + diag * Sin(a): dx3 = xc + diag * Cos(a + p2 / 64): dy3 = yc + diag * Sin(a + p2 / 64)
            _MapTriangle (sx1, sy1)-(sx2, sy2)-(sx3, sy3), source& To(dx1 + Rnd * .02, dy1 + Rnd * .02)-(dx2 + Rnd * .02, dy2 + Rnd * .02)-(dx3 + Rnd * .02, dy3 + Rnd * .02), 0
        Next
        Line (0, 0)-(xc - 1.5 * yc, _Height), &HFF000000, BF
        Line (xc + 1.5 * yc, 0)-(_Width, _Height), &HFF000000, BF
        toggle = 1 - toggle
        If toggle Then _Display
        '_Limit 80
        ro = ro - 1
    Wend
    If _KeyDown(27) Then System
Wend

Function Plasma~& ()
    cN = cN + 2
    P~& = _RGB32(127 + 127 * Sin(pR * cN), 127 + 127 * Sin(pG * cN), 127 + 127 * Sin(pB * cN))
    If P~& < &HFF808080 Then Plasma~& = &HFF000000 Else Plasma~& = &HFFFFFFFF
End Function

Sub resetPlasma ()
    pR = Rnd ^ 2: pG = Rnd ^ 2: pB = Rnd ^ 2
End Sub


Attached Files Image(s)
   
b = b + ...
Reply
#12
Can't figure out what you guys are talking about. I have a plasma TV that's as big as the sun. No static, although yesterday I mistook the sun for my set; so no matter how clear the view was, I can no longer see it. Oh well, speaking of The View, yeah, at least I'll never have to see those bitches again. So on the bright side, there's that!

Pete Confused
Fake News + Phony Politicians = Real Problems

Reply
#13
if this isn't a mod

Code: (Select All)
dim shared pi, p, q, a, b

zoom = 250

sw = 1024
sh = 768

screen _newimage(sw, sh, 32)

pi = 4*atn(1)
du = 2*pi/80
dv = pi/15

rr = 2.0
r = 1.5

a = -pi/6
b = pi/2 - pi/6

ou = 0
ov = 0

do
    oz = zoom
    do
        mx = _mousex
        my = _mousey
        mb = _mousebutton(1)
        zoom = zoom - 10*_mousewheel
    loop while _mouseinput

    cls

    xu = 0
    xv = 0

    for vv=0 to 2*pi step dv
        v = vv + ov
        xu = xu xor 1
        for u=ou to 2*pi step du
            xu = xu xor 1

            x = cos(u)*cos(v)
            y = sin(u)*cos(v)
            z = sin(v)

            roty x,y,z,a
            rotx x,y,z,b

            'parallel
            sx = -1
            sy = -sx/0.707
            sz = -0.707*sy

            'perspective
            sx = 0 
            sy = -1
            sz = 0 

            if (x*sx + y*sy + z*sz) < 0.1 then
                proj (rr + r*cos(v))*cos(u), (rr + r*cos(v))*sin(u), r*sin(v)
                x1 = sw/2 + zoom*p
                y1 = sh/2 - zoom*q
                'pset (sw/2 + zoom*p, sh/2 - zoom*q)

                proj (rr + r*cos(v))*cos(u + du), (rr + r*cos(v))*sin(u + du), r*sin(v)
                x2 = sw/2 + zoom*p
                y2 = sh/2 - zoom*q
                'line -(sw/2 + zoom*p, sh/2 - zoom*q)

                proj (rr + r*cos(v + dv))*cos(u + du), (rr + r*cos(v + dv))*sin(u + du), r*sin(v + dv)
                x3 = sw/2 + zoom*p
                y3 = sh/2 - zoom*q
                'line -(sw/2 + zoom*p, sh/2 - zoom*q)

                proj (rr + r*cos(v + dv))*cos(u ), (rr + r*cos(v + dv))*sin(u ), r*sin(v + dv)
                x4 = sw/2 + zoom*p
                y4 = sh/2 - zoom*q
                'line -(sw/2 + zoom*p, sh/2 - zoom*q)

                'proj (rr + r*cos(v))*cos(u), (rr + r*cos(v))*sin(u), r*sin(v)
                'line -(sw/2 + zoom*p, sh/2 - zoom*q)

                if xu then
                    c = 255 - 50*z
                    if v > 0.3*2*pi then
                        c = c - 50*(2*pi - v)
                    end if
                    FillTriangle x1,y1, x2,y2, x3,y3, _rgb(c,c,c)
                    FillTriangle x3,y3, x4,y4, x1,y1, _rgb(c,c,c)
                else
                    FillTriangle x1,y1, x2,y2, x3,y3, _rgb(0,0,0)
                    FillTriangle x3,y3, x4,y4, x1,y1, _rgb(0,0,0)
                end if
            end if
        next
    next

    ov = ov + dv/30
    if ov >= 59*dv/30 then ov = 0

   
    _limit 30
    _display
loop until _keyhit = 27
sleep
system

sub proj(x, y, z)
    'parallel
    'p = x + 0.707*y
    'q = z + 0.707*y

    roty x,y,z,a
    rotx x,y,z,b

    d = 10
    p = x*d/(10 + y)
    q = z*d/(10 + y)
end sub

sub rotx(x, y, z, a)
    xx = x
    yy = y*cos(a) - z*sin(a)
    zz = y*sin(a) + z*cos(a)

    x = xx
    y = yy
    z = zz
end sub

sub roty(x, y, z, a)
    xx = x*cos(a) + z*sin(a)
    yy = y
    zz = -x*sin(a) + z*cos(a)

    x = xx
    y = yy
    z = zz
end sub

sub rotz(x, y, z, a)
    xx = x*cos(a) - y*sin(a)
    yy = x*sin(a) + y*cos(a)
    zz = z

    x = xx
    y = yy
    z = zz
end sub

Sub FillTriangle (x1, y1, x2, y2, x3, y3, K As _Unsigned Long)
    Static a&, m As _MEM
    If a& = 0 Then a& = _NewImage(1, 1, 32): m = _MemImage(a&)
    _MemPut m, m.OFFSET, K
    _MapTriangle _Seamless(0, 0)-(0, 0)-(0, 0), a& To(x1, y1)-(x2, y2)-(x3, y3)
End Sub
Reply
#14
mobius strip

Code: (Select All)
dim shared pi, p, q, a, b, x, y, z, t

zoom = 450

sw = 1024
sh = 768

screen _newimage(sw, sh, 32)

pi = 4*atn(1)
du = 2*pi/100
dv = pi/20

a = 0
b = pi/4

ou = 0
ov = 0

do
    for t = 0 to 0.12 step 0.01

    cls

    xu = 0
    xv = 0

    for u=2*pi+pi/2 +du to pi step -du
        xu = xu xor 1
        for v=-pi to pi step dv
            xu = xu xor 1

            nx = sin(v)
            ny = -cos(v)
            nz = u

            roty a
            rotx b

            'parallel
            sx = -1
            sy = -sx/0.707
            sz = -0.707*sy

            'perspective
            sx = 0 
            sy = -1
            sz = 0 

            'if (nx*sx + ny*sy + nz*sz) < 0 then
                f u, v
                proj
                x1 = sw/2 + zoom*p - 200
                y1 = sh/2 - zoom*q
                'pset (x1, y1)

                f u + du, v
                proj
                x2 = sw/2 + zoom*p - 200
                y2 = sh/2 - zoom*q
                'line -(x2, y2)

                f u + du, v + dv
                proj
                x3 = sw/2 + zoom*p - 200
                y3 = sh/2 - zoom*q
                'line -(x3, y3)

                f u, v + dv
                proj
                x4 = sw/2 + zoom*p - 200
                y4 = sh/2 - zoom*q
                'line -(x4, y4)

                'line -(x1, y1)

                if xu then
                    c = 255 - 350*((u - pi)/(2*pi + pi/2))^2
                '    if v > 0.3*2*pi then
                '        c = c - 50*(2*pi - v)
                '    end if
                '    c = 255
                    FillTriangle x1,y1, x2,y2, x3,y3, _rgb(c,c,c)
                    FillTriangle x3,y3, x4,y4, x1,y1, _rgb(c,c,c)
                else
                    FillTriangle x1,y1, x2,y2, x3,y3, _rgb(0,0,0)
                    FillTriangle x3,y3, x4,y4, x1,y1, _rgb(0,0,0)
                end if
            'end if
        next


    next

    _limit 100
    _display
    next
loop until _keyhit = 27
sleep
system


sub f(u, v)
    'x = u*cos(v)
    'y = u*sin(v)
    'z = v

    x = (1 + 0.5*v*cos(0.5*(u - t)))*cos(u - t)
    y = (1 + 0.5*v*cos(0.5*(u - t)))*sin(u - t)
    z = 0.5*v*sin(0.5*(u - t))
end sub

sub proj
    'parallel
    'p = x + 0.707*y
    'q = z + 0.707*y

    roty a
    rotx b

    d = 10
    p = x*d/(10 + y)
    q = z*d/(10 + y)
end sub

sub rotx(u)
    xx = x
    yy = y*cos(u) - z*sin(u)
    zz = y*sin(u) + z*cos(u)

    x = xx
    y = yy
    z = zz
end sub

sub roty(u)
    xx = x*cos(u) + z*sin(u)
    yy = y
    zz =-x*sin(u) + z*cos(u)

    x = xx
    y = yy
    z = zz
end sub

sub rotz(u)
    xx = x*cos(u) - y*sin(u)
    yy = x*sin(u) + y*cos(u)
    zz = z

    x = xx
    y = yy
    z = zz
end sub

Sub FillTriangle (x1, y1, x2, y2, x3, y3, K As _Unsigned Long)
    Static a&, m As _MEM
    If a& = 0 Then a& = _NewImage(1, 1, 32): m = _MemImage(a&)
    _MemPut m, m.OFFSET, K
    _MapTriangle _Seamless(0, 0)-(0, 0)-(0, 0), a& To(x1, y1)-(x2, y2)-(x3, y3)
End Sub
Reply
#15
Those are really cool! 

- Dav

Find my programs here in Dav's QB64 Corner
Reply
#16
(09-15-2024, 12:04 PM)Dav Wrote: Those are really cool! 

- Dav

yeah!
b = b + ...
Reply
#17
(09-15-2024, 12:23 AM)SMcNeill Wrote:
Code: (Select All)
Screen _NewImage(640, 480, 32)
Dim m As _MEM: m = _MemImage(0)
Dim o As _Offset
Do
    o = 0
    Do
        r = Int(Rnd * 2)
        Select Case r
            Case 0: _MemPut m, m.OFFSET + o, &HFFFFFFFF As _UNSIGNED LONG
            Case 1: _MemPut m, m.OFFSET + o, &HFF000000 As _UNSIGNED LONG
        End Select
        o = o + 4
    Loop Until o = m.SIZE
Loop Until _KeyHit

There's your TV static without the sound.  I tend to keep my tv muted when it's got static on it, so this is what mine looks like.  Big Grin
That's awesome! 
I guess the sound could just be white noise created with the updated sound command. 

It's a little uniform. If you look at the above videos, and keep your eyes on the screen, one of them has this effect where certain pixels seem to stay lit a little longer or "float" on top. The third video is the most interesting, it's not just static but these patterns appear, as if the horizontal control on the set is drifting. That would also be interesting - simulating the "horizontal" control changing on an analog TV set.

Anyway, thanks for that bit of code, I could see that being a neat little effect in a game where you have a simulated analog TV.

(09-15-2024, 12:22 AM)bplus Wrote: Edit: Sun glasses for this one, epileptics do not watch!

Code: (Select All)
Screen 12
1 Cls: Color , (_BackgroundColor = 0) * -15: GoTo 1
Ha! Back in the Reagan years, I made a couple games on the C64 (or were it the TI99/4A) for an explosion effect. 
I soon realized that staring at something like that was making my ears pop! 
I think a real explosion, a single split second flash of white is more realistic.

(09-15-2024, 12:55 AM)bplus Wrote: Eye Candy #10 for @madscijr
...

Pretty cool!
Gets a little painful to stare at... I was looking for something a little smoother.
I'll get something working soon I hope, if the distractions don't keep happening!
Reply
#18
(09-15-2024, 01:03 AM)Pete Wrote: Can't figure out what you guys are talking about. I have a plasma TV that's as big as the sun. No static, although yesterday I mistook the sun for my set; so no matter how clear the view was, I can no longer see it. Oh well, speaking of The View, yeah, at least I'll never have to see those bitches again. So on the bright side, there's that!

Pete Confused
You poor child! You must be reading this on a Braille computer display (I imagine those must really exist?)

(09-15-2024, 09:24 AM)vince Wrote: if this isn't a mod

Code: (Select All)

...

Impressive!
That would make a cool background for a quasi-3D space invaders type game, with the tunnel taking some twists and turns, and the player needs to steer to avoid the walls as well as shoot the aliens...
Reply
#19
(09-15-2024, 02:44 PM)madscijr Wrote:
(09-15-2024, 01:03 AM)Pete Wrote: Can't figure out what you guys are talking about. I have a plasma TV that's as big as the sun. No static, although yesterday I mistook the sun for my set; so no matter how clear the view was, I can no longer see it. Oh well, speaking of The View, yeah, at least I'll never have to see those bitches again. So on the bright side, there's that!

Pete Confused
You poor child! You must be reading this on a Braille computer display (I imagine those must really exist?)

(09-15-2024, 09:24 AM)vince Wrote: if this isn't a mod

Code: (Select All)

...

Impressive!
That would make a cool background for a quasi-3D space invaders type game, with the tunnel taking some twists and turns, and the player needs to steer to avoid the walls as well as shoot the aliens...
" Braille computer display (I imagine those must really exist?) "

Yes they do and have existed for a very long time. Back in the early 90's when I was a computer tech I serviced a blind person's system at a local bank. He was a loan officer. He used a combination of a Braille display and optical hand held screen reader. The Braille display would bring up a line of text as he panned the optical reader over the CRT. It was quite cumbersome to use but he made it work. I imagine today's systems are much more sophisticated.

" Impressive! "

I agree, those animations are awesome vince!
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply
#20
Super cool, Vince!
Reply




Users browsing this thread: 3 Guest(s)