Vectors
Author |
Message |
Travveh

|
Posted: Wed Nov 22, 2006 11:29 am Post subject: Vectors |
|
|
I'm trying to make a pong game, and I can, most easily, but I want to use vectors, as I see suggested on almost all the pong threads. However, no one, that I've found, has ever really described how to them. If one could explain it'd be nice, or even a source example would help.
~Much Thanks |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
do_pete

|
Posted: Wed Nov 22, 2006 1:12 pm Post subject: (No subject) |
|
|
All you need is an x and y speed variable which you would add to the x and y position. Everytime you hit a paddle, you multiply x by -1 and that will reverse the direction of the paddle. |
|
|
|
|
 |
Travveh

|
Posted: Wed Nov 22, 2006 5:38 pm Post subject: (No subject) |
|
|
Yes, I'm well aware of how to make pong. However every game will be exactly the same, as the angle will never change. |
|
|
|
|
 |
Windsurfer

|
Posted: Wed Nov 22, 2006 6:46 pm Post subject: (No subject) |
|
|
Well, what he just described is a Cartesian vector... and to change the game, you add the difference between position of the center of the paddle and where the ball hit to the sideways coordinate (as in, the one that you don't multiply by -1) of the vector. If that makes any sense.
I think the best idea would be to basically play some pong games and look at how they work. |
|
|
|
|
 |
TokenHerbz

|
Posted: Thu Nov 23, 2006 6:18 am Post subject: (No subject) |
|
|
ontop of changing the x var... you will need to change the Y weather it be adding or subtracting a certain amount decided by where it hits your paddle, and at which direction, and speed your paddle is travelling at.
Math is key... get some paper and brain storm. |
|
|
|
|
 |
DKNiGHTX

|
Posted: Thu Nov 23, 2006 4:42 pm Post subject: (No subject) |
|
|
Well, unlike games such as Garry's mod which have custom types for 3D vectors, Turing has nothing of the sort. However, if you want a type to hold an x and y coord, then feel free to stick this at the top of your code:
code: | type Vector :
record
x : int
y : int
end record |
|
|
|
|
|
 |
|
|