SFML community forums
Help => General => Topic started by: Bones on November 11, 2011, 07:36:33 am
-
Hello, I've been having trouble creating a variable for a vector. Here's some pseudocode of what I would like to do:
vector2 vec(0,0)
vec.x = 1
vec.y = 5
I'm using SFML2 so I'm not sure if 2d vectors are used the same. If someone could post a sample of how to do this, that would be great.
-
what is your problem?
typedef sf::Vector2<double> Vector2d;
Vector2d vec(1, 5);
//and you are done.
//if you want to change the coords just do
vec.x = 42;
vec.y = 1337;
-
what is your problem?
typedef sf::Vector2<double> Vector2d;
Vector2d vec(1, 5);
//and you are done.
//if you want to change the coords just do
vec.x = 42;
vec.y = 1337;
I'm getting an error from setting vec:"this declaration has no storage class or type specifier." For some reason vec has no members :/
EDIT:I put it in my main function and it seems to work.
-
i think you're problem is that the vector class uses a template for it's datatype and you are omitting it.
eg:
sf::Vector2<int> vector;
where you put the datatype you wish to use in between the <> characters.
-
No, his problem is that he wrote statements outside of functions. Maybe he should read the basic chapters of his C++ book again ;)