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

Author Topic: Thor C++ Library – An SFML extension  (Read 138152 times)

0 Members and 1 Guest are viewing this topic.

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Thor C++ Library – An SFML extension
« Reply #15 on: April 30, 2011, 02:44:36 pm »
Hey, would you mind explaining me this line?

Code: [Select]
map["run"] = (Action(sf::Key::LShift) || Action(sf::Key::RShift)) && Action(sf::Key::R);

map["run"] is getting a boolean value right? from the logic operators? If so, how does it actually record the keys?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Thor C++ Library – An SFML extension
« Reply #16 on: April 30, 2011, 04:11:36 pm »
Thanks :)

Quote from: "Astrof"
So I haven't looked into it too much yet (don't shoot me) but was wondering, so the triangulation ties in with box2D?
It's not designed specifically for Box2D, nor does it use the library internally. The Triangulate() functions provide a generic interface to triangulate a set of points, so they can probably be used in combination with Box2D (I don't know the library well however).

Quote from: "DevilWithin"
Code: [Select]
map["run"] = (Action(sf::Key::LShift) || Action(sf::Key::RShift)) && Action(sf::Key::R);map["run"] is getting a boolean value right? from the logic operators? If so, how does it actually record the keys?
No, the operators || and && are overloaded for the thor::Action class, they don't return bool.

thor::Action is able to record key, mouse and joystick events, for both polling (sf::Event) and realtime input (sf::Input). The second parameter of the Action constructor specifies whether the corresponding key/mouse button/joystick button must be pressed or released once to trigger the action, or if it's enough to be held down (like in sf::Input).

The class template thor::ActionMap is continuously fed with SFML events through the method PushEvent(). At the time you check for an event to be active using IsActive(), the pushed events are searched for an occurrence of this event type. Same for realtime input. So, at the beginning of each frame, you need to reset the stored events using ClearEvents().
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Thor C++ Library – An SFML extension
« Reply #17 on: April 30, 2011, 04:41:43 pm »
Very Cool Idea! Great library! Thanks ;)

Astrof

  • Full Member
  • ***
  • Posts: 135
    • View Profile
Thor C++ Library – An SFML extension
« Reply #18 on: April 30, 2011, 08:52:57 pm »
I was just wondering about Box2D as I use that mainly for collision detection.  


Also I think I'm just stupid but how do I build this with cmake for VS2010? Specifically setting the SFMLdir

Edit:
Actually I think it's mainly me not knowing how to use cmake.  I'll not flood this thread and instead ask in the help forum.

Edit2: Okay So I get this error:
Code: [Select]

CMake Warning at CMakeLists.txt:67 (find_package):
  Could not find module FindSFML.cmake or a configuration file for package
  SFML.

  Adjust CMAKE_MODULE_PATH to find FindSFML.cmake or set SFML_DIR to the
  directory containing a CMake configuration file for SFML.  The file will
  have one of the following names:

    SFMLConfig.cmake
    sfml-config.cmake



CMake Error at CMakeLists.txt:73 (message):
  SFML directory not found.  Set SFMLDIR to SFML's top-level path (containing
  "include" and "lib" directories).


Configuring incomplete, errors occurred!


I'm trying to compile with VS2010 and SFML2.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Thor C++ Library – An SFML extension
« Reply #19 on: May 01, 2011, 03:38:43 am »
The FindSFML.cmake file must be in the CMake modules directory. It should be automatically there when you build SFML with CMake and install it (compile the INSTALL project). Make sure that you use a recent Git revision, there is also one provided on the website.

After installing SFML, try to follow this tutorial ;)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Astrof

  • Full Member
  • ***
  • Posts: 135
    • View Profile
Thor C++ Library – An SFML extension
« Reply #20 on: May 01, 2011, 03:53:11 am »
Hmm okay I'm obviously doing something wrong.  

I'm using SFML 2 from the svn.  I used cmake to build svn and was able to make a sample window and such, so that worked.  I went back and tried to compile the INSTALL project and it failed: gave me this error:

Code: [Select]

Error 1 error MSB3073: The command ""C:\Program Files (x86)\CMake 2.8\bin\cmake.exe" -DBUILD_TYPE=Release -P cmake_install.cmake
if errorlevel 1 goto :VCEnd
:VCEnd" exited with code 1. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets 113


EDIT:
Okay the problem? Admin privileges.  Stupid windows...

Now it's saying something like the SFML libraries can't be found?
Code: [Select]

Could NOT find SFML (missing:  SFML_AUDIO_LIBRARY SFML_GRAPHICS_LIBRARY SFML_WINDOW_LIBRARY SFML_SYSTEM_LIBRARY) (Required is at least version "2")
CMake Error at CMakeLists.txt:73 (message):
  SFML directory not found.  Set SFMLDIR to SFML's top-level path (containing
  "include" and "lib" directories).


Configuring incomplete, errors occurred!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Thor C++ Library – An SFML extension
« Reply #21 on: May 01, 2011, 09:00:40 am »
Yes, specify the path in the variable SFMLDIR. This is explained in my tutorial...
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Astrof

  • Full Member
  • ***
  • Posts: 135
    • View Profile
Thor C++ Library – An SFML extension
« Reply #22 on: May 01, 2011, 06:13:12 pm »
I did that that's why I'm saying it doesn't make sense.  I point it to the dir which has the include folder and the lib folder.  
"C:\SFML\branches\sfml2"
which has bindings, build, cmake, doc, examples, extlibs, include, lib, src, CMakeLists.txt, and license.txt

The tutorial is also maybe a bit off? In the tutorial it has listed a "SFML-Include-Dir" which isn't on the current one (it instead has SFML-Dir and SFMLDIR)

The errors I'm getting are about each libs debug library (but I have compiled for debug libs too).


EDIT:
Okay nevermind I fixed it.  Didn't realize that SFML installed to program files.  I so stupid...

Now I'm getting something about how PollEvent is not a member of RenderWindow?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Thor C++ Library – An SFML extension
« Reply #23 on: May 01, 2011, 07:13:31 pm »
The SVN version of SFML is outdated. You must use a recent Git revision in order to compile Thor. I provide a compatible one on my website in the download area.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Astrof

  • Full Member
  • ***
  • Posts: 135
    • View Profile
Thor C++ Library – An SFML extension
« Reply #24 on: May 01, 2011, 07:21:48 pm »
Ah okay hmm is there a way to use github with svn? Or another way that provides a simple click and update vs redownloading every time?

EDIT: okay maybe I should do some research before posting...

Downloading git now.

Astrof

  • Full Member
  • ***
  • Posts: 135
    • View Profile
Thor C++ Library – An SFML extension
« Reply #25 on: May 01, 2011, 08:46:24 pm »
Everything works now yay!

I have a small question, does the particle system only work with images or can it work with, say, Shapes or things?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Thor C++ Library – An SFML extension
« Reply #26 on: May 01, 2011, 09:20:29 pm »
Good that you managed to install it :)

No, the particle system only works with sf::Image instances. But you can use sf::RenderImage to draw any sf::Drawable to an image.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Astrof

  • Full Member
  • ***
  • Posts: 135
    • View Profile
Thor C++ Library – An SFML extension
« Reply #27 on: May 02, 2011, 12:31:17 am »
Nice to know.  Ahhhh I'm so excited that I don't know where to begin on my project.  I had this idea shelved for like years.  But hopefully It'll almost work again.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Thor C++ Library – An SFML extension
« Reply #28 on: May 02, 2011, 12:43:38 am »
That's interesting, a few weeks ago I dug out an old project of mine. For 1.5 years, I have hardly worked on it. Well, it needed some hours to port everything to SFML 2, but it was worth it... Argh, so many bugs because of the sf::Rect modification :D
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Thor C++ Library – An SFML extension
« Reply #29 on: May 22, 2011, 06:58:56 pm »
Meanwhile, I have added a way to connect thor::ActionMap with the existing thor::EventSystem. This makes it possible to connect actions to callbacks without bloating ActionMap's interface. Additionally, the classes of the Time module have been adapted so that they work with sf::Uint32 milliseconds (like sf::Clock).

As announced in my initial post, I have also implemented two classes that should help with building animations. The class Animation stores the frames of an animation and can be used by multiple Animator objects, which compute the progress and apply it to sprites. In principle they work like this:
Code: [Select]
// Create animation that has three frames with different subrects
// and durations 0.2, 0.4 and 0.1 seconds
thor::Animation explosion;
explosion.AddFrame(0.2f, sf::IntRect(...));
explosion.AddFrame(0.4f, sf::IntRect(...));
explosion.AddFrame(0.1f, sf::IntRect(...));

// Create object that animates a sf::Sprite, register animation
thor::Animator animator;
animator.AddAnimation("explode", explosion);

// Play a registered animation like this
animator.PlayAnimation("explode");

// In main loop: Update animator and apply changes to a sf::Sprite
animator.Update(passedTime);
animator.Apply(mySprite);

This is only a first draft, tell me what you think about it.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything