Qbasicnews.com

Full Version: How to stop flickering in 3D?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi!
I'm trying to make very simple 3D game on screen 12, but I have some problems.

1. Flickering! I can't stand it!! How can I make it, so It won't flicked?
2. When I put 10 rotating squares into my game, it works EXTREAMLY SLOW!!!
about 1-2 frames/sec. Why? I have seen qbasic 3D games that does have big world and doesn't work so slow!
3. I'm trying to make .1 view shooter. I the all rotations work great exept when I need to turn for example right it moves very strange! Is there any tutorial who explains how much angles and how do I need to rotate when I wan't to turn!
4. for example I have a rotating square, how can I make it filled with some color?
5. When I try to walk into my 3D world, the controls work realy offull. When I press for example 'w' key to go forword, the control doesn't allways work!!

I know its more that one question, but I realy need answers!!! Here is my 3D code:
Code:
DECLARE SUB control (theta, phi, x.center, y.center, z.center)
DIM speed AS INTEGER: speed = 20

        SCREEN 12

                    th = 180
                    ph = 1
                    x.cnt = 300
                    y.cnt = 200
                    z.cnt = 256

                    CALL control(th, ph, x.cnt, y.cnt, z.cnt)

                DO
                    SELECT CASE INKEY$:
                    CASE "a"
                           IF th = 360 THEN th = 0
                           th = th + i
                           x.cnt = x.cnt + i
                           CALL control(th, ph, x.cnt, y.cnt, z.cnt)
                    CASE "d"
                           IF th = 0 THEN th = 360
                           th = th - i
                           x.cnt = x.cnt - i
                           CALL control(th, ph, x.cnt, y.cnt, z.cnt)
                    CASE "w"
                           z.cnt = z.cnt + i
                           CALL control(th, ph, x.cnt, y.cnt, z.cnt)
                    CASE "s"
                           z.cnt = z.cnt + speed
                           CALL control(th, ph, x.cnt, y.cnt, z.cnt)
                    CASE "q"
                          x.cnt = x.cnt + speed
                           CALL control(th, ph, x.cnt, y.cnt, z.cnt)
                    CASE "e"
                          x.cnt = x.cnt - speed
                          CALL control(th, ph, x.cnt, y.cnt, z.cnt)
                    CASE "r"
                         IF ph = 360 THEN ph = 0
                         ph = ph + speed
                         CALL control(th, ph, x.cnt, y.cnt, z.cnt)
                    CASE "f"
                        IF ph = 0 THEN ph = 360
                        ph = ph - speed
                        CALL control(th, ph, x.cnt, y.cnt, z.cnt)
                    END SELECT

                LOOP UNTIL INKEY$ = CHR$(27)
CLS

SUB control (theta, phi, x.center, y.center, z.center)

        CLS
        DIM points: points = 7
        DIM c!(360)
        DIM s!(360)
        DIM x.fr(points), y.fr(points), z.fr(points)
        DIM x.new(points), y.new(points)
        DIM x(points), y(points), z(points)

              x(0) = 50
              y(0) = 50
              z(0) = -50

              x(1) = -50
              y(1) = -50
              z(1) = -50

              x(2) = -50
              y(2) = 50
              z(2) = -50

              x(3) = 50
              y(3) = -50
              z(3) = -50

              x(4) = 50
              y(4) = 50
              z(4) = 50

              x(5) = -50
              y(5) = -50
              z(5) = 50

              x(6) = -50
              y(6) = 50
              z(6) = 50

              x(7) = 50
              y(7) = -50
              z(7) = 50

                FOR angle = 1 TO 360
                   c!(angle) = COS(angle * 3.14 / 180)
                   s!(angle) = SIN(angle * 3.14 / 180)
                NEXT

        FOR i = 0 TO points

           x.fr(i) = -x(i) * s!(theta) + y(i) * c!(theta)
           y.fr(i) = -x(i) * c!(theta) * s!(phi) - y(i) * s!(theta) * s!(phi) - z(i) * c!(phi)
           z.fr(i) = -x(i) * c!(theta) * c!(phi) - y(i) * s!(theta) * c!(phi) + z(i) * s!(phi)

           x.new(i) = INT(256 * (x.fr(i) / (z.fr(i) + z.center)) + x.center)
           y.new(i) = INT(256 * (y.fr(i) / (z.fr(i) + z.center)) + y.center)

                CIRCLE (x.new(i), y.new(i)), 2, 10
        NEXT

END SUB

Please help me! The most imporant is the right/left rotation problem and flickering! Thank you very much!!! Cry
SCREEN 12 is slow. Using LINE/PSET is slow. SCREEN 12 doesn't allow paging and double buffering in that mode is a hell, so you'll get flickery animation. You are using floating point math without FFIX, and that is slow as hell.

With QB, your best choice is using SCREEN 13 or a library.
OK, I will use screen 13!! Now can you help me with all my questions? Thank you!
Here: A lightwave 3d loader in plain QB.

Uses SetVideoSeg by Plasma to eliminate flicker.

http://rel.betterwebber.com/junk.php?id=20
But I want to create everything by myself not from 'ready to go' libraries, programms etc...
Then you should learn to make your own buffering techniques.
Quote:But I want to create everything by myself not from 'ready to go' libraries, programms etc...

if you want to build on you're 3d skills then you gotta stop being a pure QB 'enthusiast' but if you want to build on you're QB skills then you can go ahead and make your own routines Big Grin