Need help in math/QBasic.

by Ben (Login The-Universe)
Admin

 
Need help in math/QBasic.
by Ben (no login)

Well, I think that I should be making games in QBasic some time soon. I've been thinking about vector images, which lead me to thinking about bezzer curves (I'll post more about my experiments with bezeir curves later), and sense of space on flat space.

So I wanna make games that give a sense of space to the user. It's the modern playable games, but not that crap nerd type RPG games. Anyways, I'm thinking:

Things will rotate on a oval:

m is the multiplier

coordinates will be:

x = m * radius * cos angle
y = radius * sin angle

And I will have 2 vanishing points of perspective (TheBOB probably knows all about that stuff)

So my first step would be to figure out the space I'm working with.

NOTICE that there are TWO ovals in the program?

Step I:

******* start of program *******
SCREEN 9
FOR i = 0 TO 75
x = COS(i * .1) * 200 + 250
y = SIN(i * .1) * 50 + 100
PSET (x, y)
NEXT
LINE (50, 100)-(320, 350)
LINE (450, 100)-(320, 350)
FOR i = 0 TO 75
x = COS(i * .1) * 100 + 285
y = SIN(i * .1) * 25 + 224
PSET (x, y)
NEXT
PRINT "this is my 3d perspective lol"
SLEEP
******* end of program *******

Step II:

This is it.

Now I'm going to implement a loop and a few lines that will be related to this perspective.

******* Start of program *******
SCREEN 9, , 1, 0

DO
i = i + 1

a = i
x0 = COS(a * .1) * 80 + 250
y0 = SIN(a * .1) * 20 + 100
x = COS(a * .1) * 200 + 250
y = SIN(a * .1) * 50 + 100
x01 = COS(a * .1) * 100 + 285
y01 = SIN(a * .1) * 25 + 224
x03 = 80 / 200 * (COS(a * .1) * 100) + 285
y03 = 80 / 200 * (SIN(a * .1) * 25) + 224
a = i + 10
x1 = COS(a * .1) * 200 + 250
y1 = SIN(a * .1) * 50 + 100
x2 = COS(a * .1) * 80 + 250
y2 = SIN(a * .1) * 20 + 100
x02 = (COS(a * .1) * 100) + 285
y02 = (SIN(a * .1) * 25) + 224
x04 = 80 / 200 * (COS(a * .1) * 100) + 285
y04 = 80 / 200 * (SIN(a * .1) * 25) + 224

LINE (0, 0)-(640, 350), 0, BF

LINE (x0, y0)-(x2, y2)
LINE (x, y)-(x1, y1)
LINE (x, y)-(x0, y0)
LINE (x1, y1)-(x2, y2)
LINE (x01, y01)-(x02, y02)
LINE (x03, y03)-(x04, y04)
LINE (x01, y01)-(x03, y03)
LINE (x02, y02)-(x04, y04)
LINE (x, y)-(x01, y01)
LINE (x1, y1)-(x02, y02)
LINE (x2, y2)-(x04, y04)
LINE (x0, y0)-(x03, y03)

'LINE (x, y)-(320, 350), 8
'LINE (x1, y1)-(320, 350), 8
'LINE (x0, y0)-(320, 350), 8
'LINE (x2, y2)-(320, 350), 8

PCOPY 1, 0
WAIT &H3DA, 8, 8
WAIT &H3DA, 8
LOOP UNTIL INP(&H60) = 1

******* End of program *******

Now this looks like crap and I'm not sure how to get the math right. 3D tutorials are BS because they use really complex math and I can't understand it. Wikipedia uses really complex formulas and equations for really simple things. I asked my dad, he said 3D means 3rd integrals. I don't understand that. So I'm stuck here and I need some guidance.

Some of my ideas:

Remember when I said there are TWO ovals?

Well, I only need one oval in the whole program, and the lines will relate to the oval and the 2 vanishing points of perspective. But what happens is this:

the perspective will make a line. I need to find the other 2 sets of coordinates.

the greek formula says:

a^2+b^2=c^2
but only c is known, a and b are not known. I cannot use SIN and COS because I don't know the angle. One thing I could do is find the rational angle:

(350-y)/(320-x)

then make linear equations:

y = rational equation * x

then have a few of them and solve for intersection by making two sets of equations and solving them. But I can't seem to understand it

I will have to plan this on paper a little bit.

Anyways, I hope you will help me, and if you do: Thank you.

Ben

Posted on Mar 12, 2009, 7:09 PM

Respond to this message   

Return to Index

Response TitleAuthor and Date
If I have time I'll look into thislkt153 on Mar 13, 12:42 AM
Forget vanishing pointsArtelius on Mar 13, 3:20 PM
 REBen on Mar 13, 5:58 PM
  BrieflyArtelius on Mar 13, 6:20 PM
  In answer to your other questionsArtelius on Mar 14, 3:05 AM
 Help!Ben on Mar 15, 6:36 PM
  That's not what I suggested...Artelius on Mar 15, 7:08 PM
   Can't say that I understand what you mean:Ben on Mar 15, 8:27 PM
    Do you understand what the diagram is showing?Artelius on Mar 15, 9:48 PM
     REBen on Mar 16, 11:34 AM
      Actually...Artelius on Mar 16, 3:46 PM
       Correct?Ben on Mar 23, 1:19 PM
        * RESUME WHAT? You already tried to END it.Clippy on Mar 23, 2:30 PM
        Wait... sorry..Ben on Mar 23, 3:45 PM
         *Good job!Artelius on Mar 23, 3:56 PM
          * How far is the eye from the monitor?Ben on Mar 25, 1:33 PM
           Just pick something that looks realisticArtelius on Mar 25, 2:46 PM
            What do you think of parallel projection?Ben on Apr 24, 6:44 PM
             * Parallel to what? Try 45 degrees to throw further...Clippy on Apr 26, 10:31 AM
        Getting a lot better!Artelius on Mar 23, 3:51 PM

 Copyright © 1999-2014 Network54. All rights reserved.   Terms of Use   Privacy Statement