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

Author Topic: Hi all!  (Read 2144 times)

0 Members and 1 Guest are viewing this topic.

rikd1977

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
Hi all!
« on: June 08, 2014, 09:24:54 pm »
ok! i just spent about 3 hrs getting sfml to work on my system using codeblocks! so i started reading sfml game development the book ok?
none of the examples work!! so?? what am i suppose to do now?!!! i dont understand this how are we supposed to learn something when nobody teaches the right code?? this is the third lib i have been through now this week! everyone say no SDL is the best, Allegro is the best, SFML is the best.... no... if you cannot use any of them how are they the best?? is there a good source for code examples that actually work? i apologize im a little upset.. i been searching for a good lib and ?? well you see what i have been dealing with! i do not want to write console games my whole life! i bought the opengl redbook that was a waste of 50$ i mean? can anyone point me someplace that will help me out?

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Hi all!
« Reply #1 on: June 08, 2014, 09:32:14 pm »
I am not even sure what you are asking or even talking about. But if you want working code for the SFML Game Development book check it out here.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Hi all!
« Reply #2 on: June 08, 2014, 09:57:07 pm »
These libraries (SDL, SFML, Allegro) work well for a lot of people. Have you considered the option that if they are not working for you then maybe you are doing something wrong on your end?

Personally I'm very happy with SFML; it works very nicely for my own projects. I've also used SDL quite a bit in the past and was very happy with it (although I didn't like the fact of it being a C API). Allegro I've never used, but I've heard lots of people say nice things about it and I certainly have no reason to believe it doesn't work.

Now, let's focus on SFML. Let's take an example straight out of the SFML 2.1 tutorials (which you should read by the way - they are very good). By combining the first example of the Drawing 2D stuff and the Shapes tutorials we get something like this:

#include <SFML/Graphics.hpp>

int main()
{
    // create the window
    sf::RenderWindow window(sf::VideoMode(800, 600), "My window");
    sf::CircleShape shape(50);

    // set the shape color to green
    shape.setFillColor(sf::Color(100, 250, 50));

    // run the program as long as the window is open
    while (window.isOpen())
    {
        // check all the window's events that were triggered since the last iteration of the loop
        sf::Event event;
        while (window.pollEvent(event))
        {
            // "close requested" event: we close the window
            if (event.type == sf::Event::Closed)
                window.close();
        }

        // clear the window with black color
        window.clear(sf::Color::Black);

        // draw everything here...
        window.draw(shape);

        // end the current frame
        window.display();
    }

    return 0;
}
 

Let's try and compile it, shall we?

Code: [Select]
$ clang++ -I/usr/local/include -L/usr/local/lib -L/usr/lib -lsfml-window -lsfml-system -lsfml-graphics ~/example.cc

To not much surprise, it builds just fine.
Now let's try to run it and see what we get

Code: [Select]
$ ./a.out

as expected we get a window with a green circle:

...

So, what exactely doesn't work?
« Last Edit: June 08, 2014, 09:59:14 pm by Jesper Juhl »

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Re: Hi all!
« Reply #3 on: June 08, 2014, 10:00:16 pm »
Guys don't waste words until you are 100% sure its not trolling.. It seems like trolling to me...

 

anything