SMOOTH rotation

Hey guys (and ladies). I am trying to move into the 3D programming of QB, and I am having a lot of trouble with glitching graphics. Anyone have some advice? I listed a simple program as an example:

SCREEN 12
LINE (0,0)-(639,463),0,BF
DELAY 1 ' <--- Maybe "SLEEP 1" for QB users, I program Firstbas

PI = 3.1415926535
FOR XX = 0 TO 5 STEP 1
FOR B = 50 TO -50 STEP -1
FOR A = 0 TO 360 STEP 1
RADIAN = A * PI / 180
X = B * COS(RADIAN) + 200
Y = 50 * SIN(RADIAN) + 200
W = 49 * SIN(RADIAN) + 200
LINE (X,Y)-(X,Y),14
LINE (X,W)-(X,W),14
NEXT A
FOR DDELAY = 1 TO 25000 STEP 1
NEXT DDELAY ' <--- Used for slowdown, might need editing
FOR A = 0 TO 360 STEP 1
RADIAN = A * PI / 180
X = B * COS(RADIAN) + 200
Y = 50 * SIN(RADIAN) + 200
W = 49 * SIN(RADIAN) + 200
LINE (X,Y)-(X,Y),0
LINE (X,W)-(X,W),0
NEXT A
NEXT B
NEXT XX

I know there must be a better way to draw the graphics than simply making the frame, "eracing" it, and then drawing the next frame.


Doug :-)


Comments

  • QUOTE:
    know there must be a better way to draw the graphics than simply making the frame, "eracing" it, and then drawing the next frame.


    not really; that's pretty much all there is to animating things. There's "double buffering" though: draw to an extra video page. once everything's draw on it, copy it to the screen, clear the video page, and draw to the video page again.
    the problem you're having is actually that the monitor is updating faster than you're drawing to the screen. It updates in the short period while the screen is blank, and the user sees this, making it appear to flicker. however, if you use the method I talked about, no blank frames will need to be drawn to the screen, unless of course you want to.




    : Hey guys (and ladies). I am trying to move into the 3D programming of QB, and I am having a lot of trouble with glitching graphics. Anyone have some advice? I listed a simple program as an example:
    :
    : SCREEN 12
    : LINE (0,0)-(639,463),0,BF
    : DELAY 1 ' <--- Maybe "SLEEP 1" for QB users, I program Firstbas
    :
    : PI = 3.1415926535
    : FOR XX = 0 TO 5 STEP 1
    : FOR B = 50 TO -50 STEP -1
    : FOR A = 0 TO 360 STEP 1
    : RADIAN = A * PI / 180
    : X = B * COS(RADIAN) + 200
    : Y = 50 * SIN(RADIAN) + 200
    : W = 49 * SIN(RADIAN) + 200
    : LINE (X,Y)-(X,Y),14
    : LINE (X,W)-(X,W),14
    : NEXT A
    : FOR DDELAY = 1 TO 25000 STEP 1
    : NEXT DDELAY ' <--- Used for slowdown, might need editing
    : FOR A = 0 TO 360 STEP 1
    : RADIAN = A * PI / 180
    : X = B * COS(RADIAN) + 200
    : Y = 50 * SIN(RADIAN) + 200
    : W = 49 * SIN(RADIAN) + 200
    : LINE (X,Y)-(X,Y),0
    : LINE (X,W)-(X,W),0
    : NEXT A
    : NEXT B
    : NEXT XX
    :
    : I know there must be a better way to draw the graphics than simply making the frame, "eracing" it, and then drawing the next frame.
    :
    :
    : Doug :-)
    :
    :
    :

  • [b][red]This message was edited by Moderator at 2003-10-25 3:3:33[/red][/b][hr]
    Sorry I didn't do this earlier. I apologize..... an example.

    NOTES: I just used the multi video page features built into basic. screen 12 only has 1 page, so I used screen 9 instead, which has 2 pages.
    There are 3 changes to your program.

    screen 12 ----> screen 9,,1,0

    which sets page 1 as active (the one you can access) and 0 as display (the one being seen).
    Of course, if you don't write to the page seen, nothing is seen, so....
    we use pcopy!

    pcopy 1,0

    thirdly, all that "draw over" code is now unncessary, so I just used a CLS.

    ----------------------------------------------
    Modified source below.
    (qb. sorry, you might have to modify for firstbas)
    ----------------------------------------------

    [code]
    SCREEN 9,,1,0
    cls
    sleep 1

    PI = 3.1415926535

    FOR XX = 0 TO 5 STEP 1
    FOR B = 50 TO -50 STEP -1
    FOR A = 0 TO 360 STEP 1
    RADIAN = A * PI / 180
    X = B * COS(RADIAN) + 200
    Y = 50 * SIN(RADIAN) + 200
    W = 49 * SIN(RADIAN) + 200
    LINE (X,Y)-(X,Y),14
    LINE (X,W)-(X,W),14
    NEXT A

    pcopy 1,0

    FOR DDELAY = 1 TO 25000 STEP 1
    NEXT DDELAY ' <--- Used for slowdown, might need editing

    cls '<-- or, could go up above, just more clear, I think, when
    'placed here

    NEXT B
    NEXT XX
    [/code]


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion