Author Topic: Twister with 8 segments  (Read 6083 times)

0 Members and 1 Guest are viewing this topic.

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Twister with 8 segments
« on: June 28, 2009 »
Don't take it too serious, it was coded in 40 mins :)

Code: [Select]
'
' Mister Twister Code Started 19:24pm 28/06/09 Finished 20:10 28/06/09
' Fast code, be kind :-) I know it's ugly :-p
' By Shockwave.
'
'===============================================================================

    #INCLUDE "TINYPTC_EXT.BI"
    #INCLUDE "WINDOWS.BI"

'-------------------------------------------------------------------------------   
'   SCREEN SETUP;   
'-------------------------------------------------------------------------------

    CONST   XRES    =    800
    CONST   YRES    =    600
   
    DIM SHARED AS INTEGER HALFX   
    DIM SHARED AS INTEGER HALFY
   
    HALFX=XRES/2
   
    DIM SHARED AS DOUBLE RAD2DEG
    DIM SHARED AS DOUBLE RAD2DEG2
    RAD2DEG =3.14/180
    RAD2DEG2=3.14/180
'-------------------------------------------------------------------------------
'   SET UP THE SCREEN.
'-------------------------------------------------------------------------------

    DIM SHARED AS UINTEGER BUFFER        ( XRES * YRES ):        ' SCREEN BUFFER
   
    DECLARE SUB TWISTER()
    DECLARE SUB RENDERLINE(BYVAL YP AS INTEGER, BYVAL XP AS INTEGER, BYVAL SLICE AS INTEGER, BYVAL TC AS UINTEGER)
'-------------------------------------------------------------------------------
'   SET UP THE SCREEN.
'-------------------------------------------------------------------------------

    PTC_ALLOWCLOSE(0)   
    PTC_SETDIALOG(1,"WWW.DBFINTERACTIVE.COM"+CHR$(13)+"FULL SCREEN?",0,1)               
    IF (PTC_OPEN("Coded by Shockwave",XRES,YRES)=0) THEN
    END-1
    END IF   

'-------------------------------------------------------------------------------
'   MAIN LOOP
'-------------------------------------------------------------------------------
    DIM SHARED AS DOUBLE OLD,DELTA,ADDMOVE
    ADDMOVE=0.0
WHILE(GETASYNCKEYSTATE(VK_ESCAPE)<> -32767 and PTC_GETLEFTBUTTON=FALSE) 
    OLD=TIMER

    TWISTER()
    PTC_UPDATE@BUFFER(0)
    SLEEP 1
    ERASE BUFFER
    DELTA=(TIMER-OLD)*150
    ADDMOVE=ADDMOVE+DELTA
WEND
    EXITPROCESS(0)
END

SUB TWISTER()
   
DIM AS INTEGER Y,X1,X2,X3,X4,X5,X6,X7,X8
DIM AS INTEGER PNR
DIM AS DOUBLE COUNTER,SV,PULSE
COUNTER=ADDMOVE

FOR Y=0 TO YRES-1

    SV=149*SIN((Y-COUNTER)*(RAD2DEG*.3))
    PULSE=110+60*SIN((Y+COUNTER)*RAD2DEG2*.15)

    X1=HALFX+(PULSE*SIN((SV+COUNTER)*RAD2DEG))
    X2=HALFX+(PULSE*SIN((SV+COUNTER+45)*RAD2DEG))
    X3=HALFX+(PULSE*SIN((SV+COUNTER+90)*RAD2DEG))
    X4=HALFX+(PULSE*SIN((SV+COUNTER+135)*RAD2DEG))
    X5=HALFX+(PULSE*SIN((SV+COUNTER+180)*RAD2DEG))
    X6=HALFX+(PULSE*SIN((SV+COUNTER+215)*RAD2DEG))
    X7=HALFX+(PULSE*SIN((SV+COUNTER+260)*RAD2DEG))
    X8=HALFX+(PULSE*SIN((SV+COUNTER+295)*RAD2DEG))
   


    IF X2>X1 THEN
        SLICE=X2-X1
        RENDERLINE(Y,X1,SLICE,RGB(SLICE,SLICE*.5,SLICE*.2))
    END IF

    IF X3>X2 THEN
        SLICE=X3-X2
        RENDERLINE(Y,X2,SLICE,RGB(SLICE*.5,SLICE*.2,SLICE))
    END IF

    IF X4>X3 THEN
        SLICE=X4-X3
        RENDERLINE(Y,X3,SLICE,RGB(SLICE*.2,SLICE,SLICE*.5))
    END IF

    IF X5>X4 THEN
        SLICE=X5-X4
        RENDERLINE(Y,X4,SLICE,RGB(SLICE*.2,SLICE*.5,SLICE))
    END IF

    IF X6>X5 THEN
        SLICE=X6-X5
        RENDERLINE(Y,X5,SLICE,RGB(SLICE,SLICE*.5,SLICE*.2))
    END IF

    IF X7>X6 THEN
        SLICE=X7-X6
        RENDERLINE(Y,X6,SLICE,RGB(SLICE*.5,SLICE*.2,SLICE))
    END IF

    IF X8>X7 THEN
        SLICE=X8-X7
        RENDERLINE(Y,X7,SLICE,RGB(SLICE*.2,SLICE,SLICE*.5))
    END IF

    IF X1>X8 THEN
        SLICE=X1-X8
        RENDERLINE(Y,X8,SLICE,RGB(SLICE*.2,SLICE*.5,SLICE))
    END IF




    PNR+=XRES
    COUNTER-=.035
NEXT
END SUB



SUB RENDERLINE(BYVAL YP AS INTEGER, BYVAL XP AS INTEGER, BYVAL SLICE AS INTEGER, BYVAL TC AS UINTEGER)
DIM AS UINTEGER PTR PP
                    PP=@BUFFER((YP*XRES)+XP)
                    asm
                    mov eax,dword ptr[TC]
                    mov ecx, [slice]
                    mov edi, [PP]
                    rep stosd
                    end asm       
END SUB
« Last Edit: September 14, 2009 by Jim »
Shockwave ^ Codigos
Challenge Trophies Won:

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: Twister with 8 segments
« Reply #1 on: June 28, 2009 »
I guess the effect would be more convincing if the radius becomes smaller at places with stronger twist.
Challenge Trophies Won:

Offline Moroboshisan

  • Senior Member
  • Amiga 1200
  • ********
  • Posts: 454
  • Karma: 18
  • C=64
    • View Profile
Re: Twister with 8 segments
« Reply #2 on: June 28, 2009 »
COOL!!!  :clap:

very smooth! It would be nice to have some random spin-ups or changing "rotating" direction...

are you planning to release something in the near future? How about jelly cubes falling from top and bouncing on top of each other?? ;)

 :cheers:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Twister with 8 segments
« Reply #3 on: June 28, 2009 »
I guess the effect would be more convincing if the radius becomes smaller at places with stronger twist.

Yes, that would work nice.

are you planning to release something in the near future? How about jelly cubes falling from top and bouncing on top of each other?? ;)
:cheers:

The next thing I do is going to be a textmode demo to be released at SUndown in September I think.. I was just killing time with this, please feel free to take it and use it :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: Twister with 8 segments
« Reply #4 on: June 30, 2009 »
I like that Shockwave, I will now disect it - thanks for the code! ;)

DrewPee
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Twister with 8 segments
« Reply #5 on: June 30, 2009 »
Happy disecting.  ^-^
Shockwave ^ Codigos
Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: Twister with 8 segments
« Reply #6 on: July 01, 2009 »
N1!
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline ferris

  • Pentium
  • *****
  • Posts: 841
  • Karma: 84
    • View Profile
    • Youth Uprising Home
Re: Twister with 8 segments
« Reply #7 on: July 04, 2009 »
Twisters are probably my all-time favorite oldschool effects :)

I hope to achieve something like this on the C-64, but that's been put on hold to finish 3 YUP prods coming out this month...;)

Anyways very nice and welldone!! You pulled it off fantastically :)
http://iamferris.com/
http://youth-uprising.com/

Where the fun's at.
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Twister with 8 segments
« Reply #8 on: July 04, 2009 »
It wasnt bad for 40 mins work :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline spitfire

  • Amiga 1200
  • ****
  • Posts: 275
  • Karma: 9
    • View Profile
Re: Twister with 8 segments
« Reply #9 on: July 04, 2009 »
Hmm why am I now in the mood for softserve ice-cream :P

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Twister with 8 segments
« Reply #10 on: July 04, 2009 »
Yum!
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Twister with 8 segments
« Reply #11 on: November 07, 2009 »
how would you texture those beauties? even if its using xor as an example ;)
As im like Ferris, love twistyness :)

Awesome dude,
Clyde.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won: