Author Topic: Quick example of new ptc lib.  (Read 5085 times)

0 Members and 1 Guest are viewing this topic.

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Quick example of new ptc lib.
« on: September 24, 2006 »
I have had a little play with the new lib by Jim and Rbraz and I can't fault it.
Here's a twisty bar thing.

Please note that you MUST have that lib to run the source.
If you don't have the lib I've included a zip with an exe.

Please note how tiny the exe is (it has been packed) but it's only 5.5kb.!

Code: [Select]
' ROTATING BAR THING BY SHOCKWAVE (C) 2006 --
'
'
'--------------------------------------------

'===============================================================================
'                      DEFINE CONSTANTS AND INITIALISE STUFF;
'===============================================================================

    OPTION STATIC
    OPTION EXPLICIT

    CONST  XRES = 640 :           ' SCREEN WIDTH.
    CONST  YRES = 480 :           ' SCREEN HEIGHT.   
    CONST  XCENT = XRES / 2 :      ' X CENTRE OF SCREEN.
    CONST  YCENT = YRES / 2 :      ' Y CENTRE OF SCREEN.

    CONST RAD_2_DEG AS DOUBLE = ( (4*ATN(1)) / 180 )
    '-------------------------------------
    ' Includes.
    '-------------------------------------
    #include "ptc.bi"
    #include "windows.bi"
   
    DIM SHARED AS UINTEGER BUFFER ( XRES * YRES ) :' THE SCREEN BUFFER.
    DECLARE SUB TWISTY()
    DIM SHARED GADD AS DOUBLE
'===============================================================================
'                               OPEN THE SCREEN;
'===============================================================================

        #define VK_A   65       'Define key "VK_A" which the ASCII code is 65 (A)

        IF ( PTC_OPEN ( "TEST BY SHOCKWAVE^DBF^S!P", XRES, YRES ) = 0 ) THEN
        END -1
        END IF
   
'       DISABLE V-SYNC;   

        ptc_setflip(0) 
'===============================================================================
'                               MAIN LOOP;
'===============================================================================
WHILE(1)
    TWISTY
    PTC_UPDATE@BUFFER(0)
    ERASE BUFFER
WEND
END

SUB TWISTY()
    DIM AS INTEGER X1,X2,X3,X4,L,V,RR
    DIM AS INTEGER Y1,Y2,Y3,Y4
    DIM Q AS INTEGER
    DIM AS DOUBLE QQ,VVV
    VVV=.7*SIN(GADD*RAD_2_DEG)
    GADD=GADD+.5
FOR Q =0 TO YRES-1
    X1=XCENT+(150*SIN((GADD+QQ)*RAD_2_DEG))
    X2=XCENT+(150*SIN((GADD+90+QQ)*RAD_2_DEG))
    X3=XCENT+(150*SIN((GADD+180+QQ)*RAD_2_DEG))
    X4=XCENT+(150*SIN((GADD+270+QQ)*RAD_2_DEG))       
    IF X2>X1 THEN
        V=X2-X1
        RR=RGB(0,0,V)
        FOR L=X1 TO X2
            BUFFER(XRES*Q+(L))=RR
        NEXT
    END IF
    IF X3>X2 THEN
        V=X3-X2
        RR=RGB(V,0,0)
        FOR L=X2 TO X3
            BUFFER(XRES*Q+(L))=RR
        NEXT
    END IF
    IF X4>X3 THEN
        V=X4-X3
        RR=RGB(V,0,V)
        FOR L=X3 TO X4
            BUFFER(XRES*Q+(L))=RR
        NEXT
    END IF
    IF X1>X4 THEN
        V=X1-X4
        RR=RGB(0,V,0)
        FOR L=X4 TO X1
            BUFFER(XRES*Q+(L))=RR
        NEXT
    END IF
    QQ=QQ+VVV
NEXT Q
END SUB

Shockwave ^ Codigos
Challenge Trophies Won:

Offline rdc

  • Pentium
  • *****
  • Posts: 1495
  • Karma: 140
  • Yes, it is me.
    • View Profile
    • Clark Productions
Re: Quick example of new ptc lib.
« Reply #1 on: September 24, 2006 »
That is cool. This lib is excellent; great work there Jim and Rbraz. I need to figure out how to do some of this cool stuff you guys do here.

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: Quick example of new ptc lib.
« Reply #2 on: September 24, 2006 »
@Shockwave:

I still love that fx - n1 !


@rbraz/jim:

cool to see your lib in action ... runs very smooth here. Well done !
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Quick example of new ptc lib.
« Reply #3 on: September 24, 2006 »
Cheers fellas.
I always liked it textured and lightsourced better though :)

See below;
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: Quick example of new ptc lib.
« Reply #4 on: September 24, 2006 »
Cheers fellas.
I always liked it textured and lightsourced better though :)

See below;


Yeah !!!!!!!!!  :||
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: Quick example of new ptc lib.
« Reply #5 on: September 24, 2006 »
Cool example !   :||
Challenge Trophies Won:

Offline MrP

  • Atari ST
  • ***
  • Posts: 176
  • Karma: 18
    • View Profile
Re: Quick example of new ptc lib.
« Reply #6 on: September 24, 2006 »
Sweet, like both of those examples. Congrats for the cool work on the lib Rbraz and Jim.....

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Quick example of new ptc lib.
« Reply #7 on: September 25, 2006 »
Yes, big thanks for the hard work on making the Lib :) It's nice to be able to do properly smooth things in Freebasic at last!
Shockwave ^ Codigos
Challenge Trophies Won: