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.


Messages - Fitzy

Pages: [1]
1
General discussions / Re: Open-sourcing my project & advice
« on: March 12, 2017, 03:51:41 pm »
Thanks for the replies.

I've added screenshots of the editor.

The scenes can be previewed similar to how  unity works. You can do a quick play of the scene then stop it (resets all changes made while in play state).

2
General discussions / Open-sourcing my project & advice
« on: March 12, 2017, 12:10:42 am »
Hello guys,

I am a long time user and limited contributor on the forums for SFML.

I finished university a while back and my dissertation was a project I had to plan from start to finish. I decided to go ahead and tackle something I was itching to try for a long time but, never got the chance to try it.

I went ahead and made a 2D game engine, using Qt, powered by SFML. This project was never finished but I believe that it is a good starting point to make a 2D game engine.

Features:
  • Unity style component based editor design
  • Lua scripting
  • Scene saving and loading

My question is, would this be something this community would be interested in seeing/using? What licence would be fair to release it under? MIT seems like a good place to start.

Below are some screenshots of the editor. There is also a "light" theme.

The screenshots are showing default, no scene loaded. Scene loaded and "playing" and some shots of lua FPS counter and json scene file.

3
Window / Re: Passing in reference.
« on: June 28, 2016, 02:56:38 am »
const sf::RenderWindow& getWindow() const
{
   return mWindow;
}
 

That function won't allow you to actually edit the window instance since it's returning a constant reference to mWindow. If you want to edit the window when you get the reference to it, then:

sf::RenderWindow& getWindow() const
{
   return mWindow;
}
 

The const at the end of function name means you won't be able to edit mWindow within the getWindow() function, which is fine because all you're doing is "return mWindow;". There are deeper meanings to what const does but I will advise you to look up C++ Const Correctness, if you want a better understanding of how it works.

Hope this helps.

4
Graphics / Re: Sprite Selection & Combined Transforms
« on: June 22, 2016, 10:28:11 pm »
I can confirm that it was indeed to do with the propagation through sf::RenderStates, my component system wasn't setup correctly and I was manipulating the sprites transform through sf::Renderstates.

Thanks a lot for the help.

5
Graphics / Re: Sprite Selection & Combined Transforms
« on: June 22, 2016, 06:14:36 pm »
Thanks for the reply.

That's exactly right, I am already working on using a custom sf::Transform instead of using sf::RenderStates to recursively combine transforms. This should theoretically fix the issue and I can use your first answer as the solution.

I will update shortly.

6
Graphics / Re: Sprite Selection & Combined Transforms
« on: June 22, 2016, 04:35:59 pm »
Thanks for taking the time to reply :).

I've tried transforming the mouse to the combined sprites transform but I get the same result (All sprites become selected from a rect of [0, 0, 200, 100] positioned at (0, 0)). All my sprites getTransform() are returning identity transforms for some odd reason. All my sprites are moved by setPosition on initialization.

I am currently trying transform.transformPoint(), and it's giving me weird results but, I can now select each sprite individually but the calculations are off (see attachments for visual representation).

Here is a minimal example of code:
Code: [Select]
auto sprite = object->getSpriteComponent()->getSprite();

auto spriteTransform = object->getCombinedTransform();

if (sprite.getGlobalBounds().contains(spriteTransform.transformPoint(m_currentMousePosition.x, m_currentMousePosition.y)))
{
object->setSelected(true);
}
else
{
object->setSelected(false);
}

m_currentMousePosition is continuously updated through Qt's widget mouse position which is equivalent to sf::Mouse::getPosition(window).

Any advice, no matter how small is very welcome.

7
Graphics / [SOLVED]Sprite Selection & Combined Transforms
« on: June 22, 2016, 03:15:08 am »
Hello, guys!

I'm currently working on my own level editor using SFML as the rendering backend. I have recently added a scene hierarchy with parent and child relationships (Everything is working as intended).

My current problem is now with implementing sprite selection in the scene, using mouse. It is only returning true if I click within the sprites bounds at position (0, 0). I'm guessing this is due to combining the transforms for each sprite. Since the RootNode is sitting at position (0, 0).

My question is, how can I deal with a scene hierarchy of objects and check if the sprite is clicked using "sprite.getGlobalBounds().contains(sf::Mouse::getPosition(m_window)"?

8
I did say I understood where the comment was coming from, people should learn the build process but it's not always as simple as that, many people come from Managed Languages like Java and C# and want to learn C++ while learning SFML, some just want to learn the basics of C++ before the build process and providing a "TEMPORARY SOLUTION" to achieve that is always welcomed.

As I said, I made this post because CMake had external dependency errors and wouldn't compile properly so for some people who are still learning the C++ build process to only get errors from Cmake which is suppose to make it easier will only frustrate people. It was just a means to an end at the time and is not suppose to be used long term, it was for easy access.

C++ isn't known for it's easy ways of doing things, think like a noob and not like a pro.

9
If you're using SFML for creating just the window and handling input, why not just something more lightweight like GLFW3 or SDL, GLFW is only desktop platforms but SDL is for all platforms.

SFML is a great library but you'd need to be utilizing more than just Window creation and Input for it to be worth using over other alternatives. This is strictly my own opinion but you get the idea.

If you're using OpenGL to draw then why not just wrap your OpenGL draw calls into a function or class and just use that?

10
To everyone saying how amazing this.... please just stop and try to learn something instead of going for premade templates that do stuff with MS specific code. There is way more amazing things than a little template that saves maybe 10 minutes of setting up linker options when your actual project will take thousands of times longer.

Learn to compile SFML yourself, its really not hard and takes 15 minutes tops if you stick to the official tutorial. Heck, the install guide for this template is just as long as building SFML. Not to mention learning to compile stuff is part of programming. Oh, and then there is the bugs (some serious ones exist on windows) that exist in 2.1 - not to mention the other great features that have been added since 2.1 in the master branch.

And if you still can't be bother to build SFML yourself........  :P   eXpl0it3r has kindly provided some nightly builds.

There's really no need for this comment at all, I see where you're coming from but some people have their reasons to go for pre-compiled solutions. The reason I added this in the first place was CMake "was" giving strange error's for Visual Studio 2013 builds.

Helping people just get the stress of figuring out how to compile when all they want to do is just get into it and start testing some code, see if it's something they love or hate. Just chill, leave people to it, if it helps just one then big bonus in my eyes.

11
Graphics / Re: Sf::View, putting player in the middle of screen
« on: June 21, 2014, 09:54:07 pm »
To remove that black around the map, you need to set it so sf::View doesn't follow the player once the bounds of the map image has been reached, once the player moves past the sf::View X or Y center AND the map bounds are not reached, set the new center on the player and move with the player but only move the view across the X or Y axis depending on the map's bounds.

Think of the player pushing invisible walls when he moves, these walls are bound to the far left, right, top and bottom of the screen and there are little walls around the player, those little walls are attached to the big walls.

Now when you move the player, the small walls push the big walls which the sf::View is attached too, once the map bounds has been reached on the negative X axis, the wall on the left side of the player is destroyed, unable to move the big wall on the far left side of the screen, thus, the sf::View no longer moves on the negative X axis untill the player moves in the positive X axis then the camera moves and all walls are reset.

No idea if that made sense to anyone but I tried to explain what I meant :P

12
No need to post in two different places as you did in this thread. Your problem might be coming from the fact that the OP was built using VS 2013 RC, not the actual release of VS 2013. What I suggest you do is follow the official tutorials to build SFML from the source using your compiler.

That's not the issue, I'm using my same method on the full release of VS2013 the template I provided was for a console application. I should have mentioned this I'm really sorry to have wasted your time. It's probably best to do what zsbzsb said and just rebuild the source with CMake and follow the install guide on this site.

My method was just meant to be a shortcut to save time on the VS2013 RC but works on VS2013 Ultimate too.

13
General discussions / Re: Tutorial on SFML 2.1 with VC++ 10
« on: September 28, 2013, 11:14:15 am »
It's all about Visual Studio 2013 ^^. Regardless, it's on RC now and I've seen no issues with it, it's faster in everyway!

14
General discussions / Re: Tutorial on SFML 2.1 with VC++ 10
« on: September 26, 2013, 01:36:52 pm »
Hey, djtmaranhao.

Is there any reason why you're using VC++ 10? Why not VC++ 11(2012) or VC++ 12(2013).

I have a post of how to setup SFML in Visual C++ 12( Visual Studio 2013 RC) I have compiled the libs for you, setup a template for you that adds the libs to the project settings so all you need to do is follow a few "unzips" in the right directories and you're set.

The link: http://en.sfml-dev.org/forums/index.php?topic=13010.0

This method just makes it far easier to beginners and uses a more up-to-date IDE which I personally think is the best C++ IDE currently available, couple that with Visual Assist X and you're good to go with C++ re-factoring, easy code navigation, syntax coloring and much more.

- Hope this helps.

15
Visual Studio 2013 Binaries + Source

Download: https://dl.dropboxusercontent.com/u/88413086/SFML-2.1-VS2013-RC.rar
There we be an installation tutorial for this setup at the bottom of the post.

Here are the Binaries for VS2013 RC, this will also work for VS2013 Preview.
I had to make some changes to the static libraries because CMake was giving
me errors linking the 'libs' incorrectly causing syntax errors "&quot".
The way to bypass this issue was to link the libs for static builds implicitly like:

Quote
#ifdef SFML_STATIC
#pragma comment(lib, "glew.lib")
#pragma comment(lib, "freetype.lib")
#pragma comment(lib, "jpeg.lib")
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "winmm.lib")
#pragma comment(lib, "gdi32.lib") 
#endif // SFML_STATIC

As long as SFML_STATIC is in the pre-processor in the project settings for the static build
these libs will link flawlessly. I know it's bad practice but I find explicitly calling them like this
much cleaner and the programmer can see exactly what's happening in their project.
THIS IS PURELY MY OWN OPINION AND YOU ARE NOT EXPECTED TO FOLLOW MY VIEWS

Visual Studio 2013 RC Template

Download: https://dl.dropboxusercontent.com/u/88413086/SFML%20Game%20Template.rar

This template has the above SFML_STATIC code snippet and the official SFML code snippet from the
official green circle installation test code.

Installation Instructions

Make sure you're using Visual Studio 2013 Preview or RC(Release Candidate) and Winrar!

1. Start by extracting the Binaries folder to your C:/ drive.
    So it appears like this: C:\SFML\SFML-2.1
    IT IS IMPORTANT YOU COPY IT TO THE C:/ OTHERWISE THE PROJECT SETTINGS WILL BE MESSED UP!

2. Then extract the template file to your Visual Studio path Microsoft Visual Studio 12.0\VC\vcprojects
    Mine appears like: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcprojects
    It should now have a new folder in there named SFML Game and inside the folder it should have the files.

3. Now go to the C:\SFML\SFML-2.1 folder and open the bin folder, you should see loads of .dll files, this is perfect!
    We need to copy all of these .dll files and copy them into the Visual Studio 2013 bin folder so when we
    run our project it will be able to find the runtime components our program needs to run!
   
    Copy all of those .dll files to: Microsoft Visual Studio 12.0\VC\bin
    Again, mine looks like this: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin

Now fire up Visual Studio 2013 and start a new project, click on Visual C++, you should now see SFML Game!
Open this and open SFML Game project file and call it what you like. You should now see the following:

Quote
#ifdef SFML_STATIC
#pragma comment(lib, "glew.lib")
#pragma comment(lib, "freetype.lib")
#pragma comment(lib, "jpeg.lib")
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "winmm.lib")
#pragma comment(lib, "gdi32.lib") 
#endif // SFML_STATIC


#include <SFML/Graphics.hpp>

//Default test code from the SFML website
int main()
{
   sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
   sf::CircleShape shape(100.f);
   shape.setFillColor(sf::Color::Green);

   while (window.isOpen())
   {
      sf::Event event;
      while (window.pollEvent(event))
      {
         if (event.type == sf::Event::Closed)
            window.close();
      }

      window.clear();
      window.draw(shape);
      window.display();
   }

   return 0;
}

You now have 4 compiling options.
  • Debug
  • Debug Static
  • Release
  • Release Static

Try each of these settings and build the sample code, vuala! We hopefully have lift off!

Small edit to correct the version, it's SFML 2.1! not 2.0 - Sorry.

Pages: [1]