1
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Pages: [1]
2
Graphics / Problem with Shape and adress stuff
« on: May 15, 2015, 05:49:25 pm »
Hi everybody,
I'm creating a little c++ game with sfml, here is a resume of what I want to do :
In my game there is Meteor and two type of these, Circle meteor and Rectangle Meteor. So I wanted to use polymorphism to stock these both type of meteor which are inherited from the same Meteor Class. So usually i have a virtual render function in Meteor that's like this :
And after this the treatment is obviously different in Circle Meteor and Rectangle one. Here is the code of CircleMeteor, I don't put Rectangles one because anyway it will work the same way :
And in the RenderManager i use it like that :
The "= new RectangleShape(Vector2f(120,50));" stuff was for iniatilazing I could have use "nullptr" but it was crashing since my assignation don't work in "BubbleMeteor::render(...);" I tested a lot of things and this is the one giving me the best result. I see every meteor with their respective color, rotation, position (So i can conclude "Meteor::render(...)" work great) but they don't adapt to size and circle or rectangle.
Can you say me how to fix this ?
Thanks you very much for you time.
I'm creating a little c++ game with sfml, here is a resume of what I want to do :
In my game there is Meteor and two type of these, Circle meteor and Rectangle Meteor. So I wanted to use polymorphism to stock these both type of meteor which are inherited from the same Meteor Class. So usually i have a virtual render function in Meteor that's like this :
virtual void render(sf::Shape &shape);
And after this the treatment is obviously different in Circle Meteor and Rectangle one. Here is the code of CircleMeteor, I don't put Rectangles one because anyway it will work the same way :
void BubbleMeteor::render(sf::Shape &shape) {
shape = CircleShape(m_size.x / 2);
Meteor::render(shape);
}
shape = CircleShape(m_size.x / 2);
Meteor::render(shape);
}
void Meteor::render(sf::Shape &shape) {
shape.setFillColor(m_color);
shape.setOutlineColor(Color::Black);
shape.setOutlineThickness(8);
shape.setOrigin(0, 0);
shape.setPosition(m_pos);
shape.setRotation(m_rotation);
}
shape.setFillColor(m_color);
shape.setOutlineColor(Color::Black);
shape.setOutlineThickness(8);
shape.setOrigin(0, 0);
shape.setPosition(m_pos);
shape.setRotation(m_rotation);
}
And in the RenderManager i use it like that :
for (int i = 0; i < (int)m_metMng->getArray().size(); i++) {
Shape *shape = new RectangleShape(Vector2f(120,50));
m_metMng->getArray()[i]->render(*shape);
m_app->draw(*shape);
}
Shape *shape = new RectangleShape(Vector2f(120,50));
m_metMng->getArray()[i]->render(*shape);
m_app->draw(*shape);
}
The "= new RectangleShape(Vector2f(120,50));" stuff was for iniatilazing I could have use "nullptr" but it was crashing since my assignation don't work in "BubbleMeteor::render(...);" I tested a lot of things and this is the one giving me the best result. I see every meteor with their respective color, rotation, position (So i can conclude "Meteor::render(...)" work great) but they don't adapt to size and circle or rectangle.
Can you say me how to fix this ?
Thanks you very much for you time.
3
General / Re: SFML 2.0 + Code::Blocks' autocompletion = problem
« on: May 13, 2013, 09:58:42 pm »
This problem will probably came from your code::block settings, check them and see for something looking like this "Autocompletition launch when type # letter :" it's in settings > editor (next, search a little bit).
So i think this is the root of the probleme because by default autocompletition launch when you type 4 letter, and "x." is only two letters.
So i think this is the root of the probleme because by default autocompletition launch when you type 4 letter, and "x." is only two letters.
Pages: [1]