
                    Vic's QBasic Programming Tutorial

                        Basic Tutorial III.V (3.5)

                       GAME TEQUINIQUES REVISTITED!!



-----------------------------------------------------------------------------

Ok! OK!!!

I have had enought E-mails about people not understanding my game tutorial...
So, I figured it was probly my fault for not explaining it good enough...

This tutorial works hand in hand with tutor #3 so make sure you read it
first...

----

First of all, I will once again I will cover How to move a sprite...
I will cover it a few times now...

---------------------------------------------------------------------------

OK! here we go!

Every Sprite has a X value and a Y value...

Let me draw a grid for you to get the picture better...


     1    2    3   4    5    6    7    8    9    10   11   12
  -------------------------------------------------------------
1 |    |    |    |    |    |    |    |    |    |    |    |    |
  |    |    |    |    |    |    |    |    |    |    |    |    |
  -------------------------------------------------------------
2 |    |    |    |    |    |    |    |    |    |    |    |    |
  |    |    |    |    |    |    |    |    |    |    |    |    |
  -------------------------------------------------------------
3 |    |    |    |    |    |    |    |    |    |    |    |    |
  |    |    |    |    |    |    |    |    |    |    |    |    |
  -------------------------------------------------------------
4 |    |    |    |    |    |    |    |    |    |    |    |    |
  |    |    |    |    |    |    |    |    |    |    |    |    |
  -------------------------------------------------------------
5 |    |    |    |    |    |    |    |    |    |    |    |    |
  |    |    |    |    |    |    |    |    |    |    |    |    |
  -------------------------------------------------------------


Do you remember your times table??   Its exactly like that...

Ok, Imagine that We wanted to put sprite at this point (where the XX is)


     1    2    3   4    5    6    7    8    9    10   11   12
  -------------------------------------------------------------
1 |    |    |    |    |    |    |    |    |    |    |    |    |
  |    |    |    |    |    |    |    |    |    |    |    |    |
  -------------------------------------------------------------
2 |    |    |    |    |    |    |    |    |    |    |    |    |
  |    |    |    |    | XX |    |    |    |    |    |    |    |
  -------------------------------------------------------------
3 |    |    |    |    |    |    |    |    |    |    |    |    |
  |    |    |    |    |    |    |    |    |    |    |    |    |
  -------------------------------------------------------------
4 |    |    |    |    |    |    |    |    |    |    |    |    |
  |    |    |    |    |    |    |    |    |    |    |    |    |
  -------------------------------------------------------------
5 |    |    |    |    |    |    |    |    |    |    |    |    |
  |    |    |    |    |    |    |    |    |    |    |    |    |
  -------------------------------------------------------------

Believe it or not, the X value would be 5 and the Y value would equal 2...
So its like this...

X = 5
Y = 2

Remebmer from the graphics tutorial??

X goes left to right, and Y goes up and down...

---

Ok, You most likely get that...
If you don't, just think about it for a while...

---

Now, What if we wanted to move that XX one space to the RIGHT?  What would
its X value be now??

Let me show you this...


    1    2    3   4    5    6    7    8    9    10   11   12
  -------------------------------------------------------------
1 |    |    |    |    |    |    |    |    |    |    |    |    |
  |    |    |    |    |    |    |    |    |    |    |    |    |
  -------------------------------------------------------------
2 |    |    |    |    |    |    |    |    |    |    |    |    |
  |    |    |    |    | XX | ZZ |    |    |    |    |    |    |
  -------------------------------------------------------------
3 |    |    |    |    |    |    |    |    |    |    |    |    |
  |    |    |    |    |    |    |    |    |    |    |    |    |
  -------------------------------------------------------------
4 |    |    |    |    |    |    |    |    |    |    |    |    |
  |    |    |    |    |    |    |    |    |    |    |    |    |
  -------------------------------------------------------------
5 |    |    |    |    |    |    |    |    |    |    |    |    |
  |    |    |    |    |    |    |    |    |    |    |    |    |
  -------------------------------------------------------------

The XX is where the sprite is now, and ZZ is where we want the sprite to
go, which is one space to the right...

So, The X value of the XX is 5 remember, if we want it to be one place to
the right, (where the ZZ is) what should the next X value be?  6 right?

So, if we want the sprite to move one space to the right what should we do?

This is what it used to equall...

X = 5
Y = 2

Now, it equalls

X = 6
Y = 2

Remember, 
X = left to right and
Y = up and down,

So, now, if we wanted to move the sprite down one, we would change the Y
value...

So the coordinates would equal

X = 6
Y = 3

So it would now be here...  (where the AA is)

    1    2    3   4    5    6    7    8    9    10   11   12
  -------------------------------------------------------------
1 |    |    |    |    |    |    |    |    |    |    |    |    |
  |    |    |    |    |    |    |    |    |    |    |    |    |
  -------------------------------------------------------------
2 |    |    |    |    |    |    |    |    |    |    |    |    |
  |    |    |    |    | XX | ZZ |    |    |    |    |    |    |
  -------------------------------------------------------------
3 |    |    |    |    |    |    |    |    |    |    |    |    |
  |    |    |    |    |    | AA |    |    |    |    |    |    |
  -------------------------------------------------------------
4 |    |    |    |    |    |    |    |    |    |    |    |    |
  |    |    |    |    |    |    |    |    |    |    |    |    |
  -------------------------------------------------------------
5 |    |    |    |    |    |    |    |    |    |    |    |    |
  |    |    |    |    |    |    |    |    |    |    |    |    |
  -------------------------------------------------------------


If we were to put this into a formula, what would it look like?

If we wanted to move the sprite ONE (1) space to the right what should
we put???

X = X + 1

Imagine X was equal to 5...  Now what does X equal?
6 right???  YES! That would be one space to the right...

If we wanted to move the sprite one down what would we do?

Y = Y + 1

So, if Y was equal to 2 Y would now equal 3!!!  One space down...

--------

I don't know how I can make this any clearer...
IF you still don't understand it, just keep looking at others source code...

-----------------------------------------------------------------------------

