Dark Bit Factory & Gravity
PROGRAMMING => Freebasic => Topic started by: Shockwave 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.!
' 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
-
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.
-
@Shockwave:
I still love that fx - n1 !
@rbraz/jim:
cool to see your lib in action ... runs very smooth here. Well done !
-
Cheers fellas.
I always liked it textured and lightsourced better though :)
See below;
-
Cheers fellas.
I always liked it textured and lightsourced better though :)
See below;
Yeah !!!!!!!!! :||
-
Cool example ! :||
-
Sweet, like both of those examples. Congrats for the cool work on the lib Rbraz and Jim.....
-
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!