Dark Bit Factory & Gravity

PROGRAMMING => Freebasic => Topic started by: Shockwave on August 10, 2007

Title: Lack of inspiration leads to another shit effect.
Post by: Shockwave on August 10, 2007
I can't seem to get into my programming at the moment, I don't seem to be having any good ideas.. I did this strange looking thing tonight, I have been drinking so I apologise.

Code: [Select]

        OPTION STATIC
        OPTION EXPLICIT
       
        CONST   XRES = 800
        CONST   YRES = 600

        DIM SHARED AS INTEGER HALFX = (XRES/2)
        DIM SHARED AS INTEGER HALFY = (YRES/2)

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

        DIM SHARED AS DOUBLE GAP =2
        DIM SHARED AS INTEGER RES = 10
        DIM SHARED AS DOUBLE SIZE = 10000
        DIM SHARED AS DOUBLE MOVE = 0
        DIM SHARED AS DOUBLE XX( RES * 4)
        DIM SHARED AS DOUBLE YY( RES * 4)

        DIM SHARED AS DOUBLE XPOS,YPOS
        DIM SHARED AS INTEGER XTARG,YTARG

        XTARG=0
        YTARG=0
        XPOS=0
        YPOS=0
       
        DIM SHARED AS UINTEGER  BUFFER ( XRES * YRES )
             
             
        DECLARE SUB MAKE_GRID()
        DECLARE SUB DRAW_WAFFLE(BYVAL W_SIZE AS DOUBLE)
        DECLARE SUB EDGE(BYVAL X1 AS INTEGER , BYVAL Y1 AS INTEGER , BYVAL X2 AS INTEGER , BYVAL Y2 AS INTEGER , BYVAL LR AS INTEGER, BYVAL LG AS INTEGER, BYVAL LB AS INTEGER)             
        DECLARE SUB DRAW_STACK()

        PTC_ALLOWCLOSE(0)
        PTC_SETDIALOG(0,"",0,0)   
        IF (PTC_OPEN("<( - DBF - )>",XRES,YRES)=0) THEN
            END-1
        END IF         

'
        MAKE_GRID()
 
WHILE(GETASYNCKEYSTATE(VK_ESCAPE)<>-32767)   
    DRAW_STACK()
'    DRAW_WAFFLE(30+10*SIN(timer*3))
    PTC_UPDATE@BUFFER(0)
    ERASE BUFFER
WEND

SUB DRAW_STACK()
    DIM X AS INTEGER
    DIM CUNT AS DOUBLE
    CUNT=.001+(GAP*10)
    MOVE=MOVE+.025
   
    XPOS=XPOS+((XTARG-XPOS)/28)
    YPOS=YPOS+((YTARG-YPOS)/28)   
   
    IF MOVE>GAP THEN
        MOVE=MOVE-GAP
        XTARG= ((RND(1)-.5))*5100
        YTARG= ((RND(1)-.5))*5100
    END IF
   
    FOR X=10 TO 1 STEP-1
        DRAW_WAFFLE(CUNT-MOVE)
        CUNT=CUNT-GAP
    NEXT
END SUB


SUB EDGE(BYVAL X1 AS INTEGER , BYVAL Y1 AS INTEGER , BYVAL X2 AS INTEGER , BYVAL Y2 AS INTEGER , BYVAL LR AS INTEGER, BYVAL LG AS INTEGER, BYVAL LB AS INTEGER)
'-------------------------------------------------------------------------------
'
' THIS LINE ROUTINE IS NOT VERY FAST BUT IT WORKS. THANKS TETRA.
' USAGE:
' EDGE ( X1 , Y1 , X2 , Y2 , R , G , B )
'
'-------------------------------------------------------------------------------
        DIM xdistance AS DOUBLE
        DIM ydistance AS DOUBLE
        DIM TC AS INTEGER       
        DIM i AS INTEGER
        DIM h2 AS INTEGER
       
        DIM StartX AS DOUBLE
        DIM StartY AS DOUBLE
        DIM XRatio AS DOUBLE
        DIM YRatio AS DOUBLE

        TC = RGB ( LR,LG,LB )

        xdistance = X2 - X1
        ydistance = Y2 - Y1

        h2 = sqr( xdistance * xdistance + ydistance * ydistance )
       
        StartX = X1
        StartY = Y1

        XRatio = xdistance * ( 1.0 / h2 )
        YRatio = ydistance * ( 1.0 / h2 )
       
        for i = 0 to h2
           
            IF  STARTX>0 AND STARTY>0 AND STARTX<XRES AND STARTY<YRES THEN
            BUFFER ( INT(StartX) + (INT(StartY) * XRES ) ) = TC
        END IF       
       
            StartX = StartX + XRatio
            StartY = StartY + YRatio
        next i



END SUB

SUB DRAW_WAFFLE(BYVAL W_SIZE AS DOUBLE)
   
    DIM AS INTEGER X,TX1,TY1,TX2,TY2,SV
   
   
    SV = 255/W_SIZE
   
    IF SV>255 THEN SV=255
    FOR X=0 TO RES-1
       
        TX1 = ((XX(X)+XPOS) / W_SIZE)+HALFX
        TY1 = ((YY(X)+YPOS) / W_SIZE)+HALFY
       
        TX2 = ((XX(X+RES)+XPOS) / W_SIZE)+HALFX
        TY2 = ((YY(X+RES)+YPOS) / W_SIZE)+HALFY
       
        IF TY1<0 THEN TY1=0
        IF TY1>YRES THEN TY1=YRES
        IF TY2<0 THEN TY2=0
        IF TY2>YRES THEN TY2=YRES
        IF TX1<0 THEN TX1=0
        IF TX1>XRES THEN TX1=XRES
        IF TX2<0 THEN TX2=0
        IF TX2>XRES THEN TX2=XRES


        EDGE (TX1,TY1,TX2,TY2,SV,SV,SV)

    NEXT

    FOR X=0 TO RES-1
       
        TX1 = ((XX(X+RES+RES)+XPOS) / W_SIZE)+HALFX
        TY1 = ((YY(X+RES+RES)+YPOS) / W_SIZE)+HALFY
        TX2 = ((XX(X+RES+RES+RES)+XPOS) / W_SIZE)+HALFX
        TY2 = ((YY(X+RES+RES+RES)+YPOS) / W_SIZE)+HALFY

        IF TY1<0 THEN TY1=0
        IF TY1>YRES THEN TY1=YRES
        IF TY2<0 THEN TY2=0
        IF TY2>YRES THEN TY2=YRES
        IF TX1<0 THEN TX1=0
        IF TX1>XRES THEN TX1=XRES
        IF TX2<0 THEN TX2=0
        IF TX2>XRES THEN TX2=XRES
       
        EDGE (TX1,TY1,TX2,TY2,SV,SV,SV)

    NEXT


   
END SUB



SUB MAKE_GRID()
    DIM AS INTEGER X
    DIM AS DOUBLE INTR 
    DIM AS DOUBLE STRT
    DIM AS DOUBLE ACTUAL
   
 
    INTR = (SIZE  / (RES-1))
    STRT = (-(SIZE/ 2))
    ACTUAL = STRT
   
    ' CALCULATE GRID
   
    FOR X=0 TO RES-1

        XX(X) = ACTUAL
        YY(X) = STRT

        XX(X+RES) =  ACTUAL
        YY(X+RES) = -STRT

        YY(X+RES+RES) = ACTUAL
        XX(X+RES+RES) = STRT

        YY(X+RES+RES+RES) = ACTUAL
        XX(X+RES+RES+RES) = -STRT
       
         ACTUAL = ACTUAL + INTR
       
    NEXT
   
END SUB

Come on, you must have had mental blocks too? :) In my mind this idea looked so cool too.. It just doesn't work.
Title: Re: Lack of inspiration leads to another shit effect.
Post by: Jim on August 11, 2007
It reminds me of one of Parabellum's yabasic demos that had a ball infinitely falling through a set of grid lines like that.

I'm not just mentally blocked at the moment.  I'm not motivated either.

Jim


Title: Re: Lack of inspiration leads to another shit effect.
Post by: Merick on August 11, 2007
Maybe change it so that the lines look kinda like steel girders, then add a ragdoll stick-figure and have it bounce off them...
Title: Re: Lack of inspiration leads to another shit effect.
Post by: benny! on August 11, 2007
@Shocky:
Like it - good start. Possible ideas to improve it :

- make it a tunnel (fly through the grid)
- make it infinitve to the left and right ( now it seems that the second row of lines
are cutted to the left / right
- increase the line width for the lines which are "nearer to the viewer" to improve
3D fx ?
Title: Re: Lack of inspiration leads to another shit effect.
Post by: Shockwave on August 11, 2007
Thanks for the tips :) This code is now in the bin though, I just posted it in case anyone wanted to use it.
Title: Re: Lack of inspiration leads to another shit effect.
Post by: DrewPee on August 13, 2007
Shockwave,
looks the dogs to me . . . I will be looking closely at the code . . . thanks!

Drew
Title: Re: Lack of inspiration leads to another shit effect.
Post by: Shockwave on August 13, 2007
It could probably look ok if the lines closest got thicker as Benny suggested but I've stopped on this now :)

looks the dogs to me . . . I will be looking closely at the code . . . thanks!

It just looks bollocks to me mate :)
It reminds me of one of Parabellum's yabasic demos that had a ball infinitely falling through a set of grid lines like that.

Ah yes, Ball chase. that was really nice. Much better than this :D
Title: Re: Lack of inspiration leads to another shit effect.
Post by: Ghost^BHT on August 18, 2007
ok  I will first apologize for being drunk and incoherebt .... i can see this infinit grid thing morphing from a 3d starfield then  zooming twords the z point as well as rotating through  th x and y and finally morphing to the starfield again  only this time parallax starfield while a scroller becomes sinus or 3d sinus depemding on mode plus the usual cubic dissoreder ont he upper and lower bounds with logo would be  akiller intro/crcktro ... well if i cud code as well as i drink it would be killer anyways
 dont hit me
Title: Re: Lack of inspiration leads to another shit effect.
Post by: Shockwave on August 18, 2007
K++
Title: Re: Lack of inspiration leads to another shit effect.
Post by: stormbringer on August 18, 2007
add a C64-like writer with some cool C64 charset, a chip-tune and you should end up with a nice cracktro IMO

Best,

Stormbringer