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

Author Topic: Can SMFL do classes?  (Read 2928 times)

0 Members and 1 Guest are viewing this topic.

drarem

  • Newbie
  • *
  • Posts: 5
    • View Profile
Can SMFL do classes?
« on: May 21, 2011, 02:28:33 pm »
In other words,

I want to have something like:

SFML * app;
app = new SFML(1024,768,32,fullscreen);

The value in this is I can build everything else into the class and only use the main code to do my calls. I am beginning to realize how simple SFML is and wondering this may make it somewhat more complicated but anyway..

app->loadsprites(char *spritedat, IMG *img, int xwid, int yhgt, int count);

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Can SMFL do classes?
« Reply #1 on: May 21, 2011, 03:30:18 pm »
I don't really understand your problem. Why don't you write an own class which has the behavior you want to achieve?

By the way, you don't need new to create an object of a class.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Can SMFL do classes?
« Reply #2 on: May 21, 2011, 03:35:25 pm »
Erhm.. That looks like HGE... The gods forbid that SFML ever adopts that design!
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

drarem

  • Newbie
  • *
  • Posts: 5
    • View Profile
Can SMFL do classes?
« Reply #3 on: May 21, 2011, 03:40:05 pm »
Never heard of HGE, maybe picked it up along the way as a bad habit.

As for your question, I was thinking of not having to pass by reference the App pointer everywhere I go but then again that is what you're suggesting? Never thought of it that way.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Can SMFL do classes?
« Reply #4 on: May 21, 2011, 03:51:19 pm »
Quote from: "drarem"
As for your question, I was thinking of not having to pass by reference the App pointer everywhere I go
Passing it everywhere is certainly a bad idea. Only pass the sf::RenderWindow to the functions that really need access to it, i.e. input-handling or rendering functions. An even worse idea however is to have the window as a global variable.

But can you explain a little more precisely what you actually want to do? Do you want a single god class that is responsible of everything? What doesn't please you at SFML's current design?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

drarem

  • Newbie
  • *
  • Posts: 5
    • View Profile
Can SMFL do classes?
« Reply #5 on: May 21, 2011, 04:12:49 pm »
I don't want to have to recreate the wheel every time in my games using the SFML library. Code one object manager, sprite manager, ... and be done with it. If I don't put my stuff into a class, how will my class be able to see SFML stuff without passing it? Let me know if I'm not making sense.

Rather than picking the pieces ouf of one game to start another, I would rather use something more modular.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Can SMFL do classes?
« Reply #6 on: May 21, 2011, 04:52:18 pm »
Quote from: "drarem"
I don't want to have to recreate the wheel every time in my games using the SFML library.
Do it like me: Develop a library that contains commonly used functionality and reuse code.

Quote from: "drarem"
Code one object manager, sprite manager, ... and be done with it.
Then do it ;)

SFML is a basic multimedia library, no game engine. So, these things are out of scope for a direct integration. But you can use one of the many extensions (look at the wiki) or program your own one. It needn't be open source.

Quote from: "drarem"
If I don't put my stuff into a class, how will my class be able to see SFML stuff without passing it? Let me know if I'm not making sense.
Your classes can also create SFML objects on their own, depending on the responsibility they have. Otherwise, pass objects around, where is the problem?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: