Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

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.

Topics - yannik

Pages: [1]
Graphics / Overriding sf::RectangleShape::draw
« on: April 16, 2017, 12:52:43 pm »
I derive a class Square from RectangleShape. The Square also contains a text I want to draw. But when I override draw to draw the text, how do I also draw the rectangle? Do I have to create yet another class or is there something I'm missing? Here's the code

#include <SFML/Graphics/RectangleShape.hpp>
#include <SFML/Graphics/Text.hpp>
#include <SFML/Graphics/Font.hpp>
#include <SFML/Graphics/RenderTarget.hpp>
#include <SFML/Graphics/RenderWindow.hpp>

#include <string>

class Square : public sf::RectangleShape
    sf::Text            mText;

                                Square(const sf::Font& font, sf::Vector2f position, const std::string& s = "");

    void                        update();

    void                        draw(sf::RenderTarget& target, sf::RenderStates states) const;

Square::Square(const sf::Font& font, sf::Vector2f position, const std::string& s)
        mText.setPosition(sf::Vector2f(position.x + 16, position.y + 8));

        setSize(sf::Vector2f(48, 48));

void Square::draw(sf::RenderTarget& target, sf::RenderStates states) const

void Square::update()

int main()
        sf::RenderWindow window(sf::VideoMode(640, 480), "");
        sf::Font font;
        Square square(font, sf::Vector2f(10, 10), "A");

Thanks in advance.

General discussions / SFML Game Development review
« on: April 03, 2017, 02:13:04 pm »
I had no prior experience with SFML and wanted to learn how to write games with C++, so I bought "SFML Game Development". I'm currently at chapter 9 and have noticed a few things I'd like to say.
First of all, the price. It's quite expensive, and comparing it to other books in the genre (like this german c++ book) I expect more detail when it comes to explaining how to get the software running. The aforementioned book costs less, is three times the size and includes not only a CD with an automated installer, but also detailed tutorials about how to set the IDE, compiler and even some libraries like boost or Qt up. "I'm sorry we can't tell you how to do this, but I'm sure you'll find some tutorials on the internet" just doesn't cut it.
Concerning the content, I really appreciate the modern C++11 style and code-design and the relatively detailed explanations in the first three chapters. But later on, explanations become more and more superficial and leave much to be desired - for example on page 116, where the "StateStack" is covered. Many times, it's explained WHY we need something, but not just how all of this works together and why something's designed this particular way. Like "To do this, we need this class: " (A lot of code.) Understood? Great. Now we implement it. And while it's explained how to use a factory to create states, I'm left wondering which class needs a StateStack. The world or the application class? Or is the application a statestack? Same goes for the Context structure, I want to know which classes need one and why. I need diagrams and pictures showing me where all the classes fit in and work hand in hand. Even after copying every single line of code I still had a lot of questions and couldn't even get the damn thing to run, it was just too much input and too little explanation.
Lastly, I bought this book so I could learn the basics about game programming. In my opinion, saying "we can't tell you anything at all about GLSL because it's too complicated", "Steering behaviors are very interesting. Don't hesitate to search the internet" or "Separating Axis Theorom is a popular algorithm, read more about it here: ..." collides with the purpose of this book. Why not even try to explain at least a little bit? I bought the book so I could learn about this. I don't need a full explanation, just the basics and a few examples would suffice. I don't know the first thing about GLSL, but the .frag files enclosed are just a few lines long and don't look too complicated.
I hope this doesn't look too much like some lampoon, I wouldn't read the book if I didn't like it. And I'll see how much I've learned when I try to implement some of my own ideas..

Pages: [1]