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 - DasOhmoff

Pages: [1] 2
1
General / Re: Update origin in sprite before rendering?
« on: September 02, 2015, 02:55:06 pm »
Thanks for you answers guys.

I understood what's the point.

2
General / Update origin in sprite before rendering?
« on: September 01, 2015, 06:24:57 pm »
Hi,

just wanted to ask if there is a way to update the origin of the sprite before drawing it.

This is not possible:
sf::FloatRect gb = sprite.getGlobalBounds();
sprite.setOrigin(gb.width / 2, gb.height / 2);
sprite.rotate(90);
sprite.setOrigin(0, 0);
 

I setted the origin to the center and rotated it but the rotation point is not in the center.
It rotates aroung the point 0, 0.
I think the code would work if the origin would not be updated when the sprite is drawen.

I NEED the origin to be at 0, 0 but I also want the sprite to rotate from in the center...

Is there a way to do it?

3
Graphics / sf::Texture and sf::Sprite not working with std::tuple
« on: August 20, 2015, 11:07:49 pm »
Hi, I have a problem and I can not solve it...

Code: [Select]
#include <SFML/Graphics.hpp>

#include <iostream>
#include <vector>
#include <tuple>

enum class ID
{
Background,
Player
};

std::vector<std::tuple<ID, sf::Texture, sf::Sprite>> drawables;

void add(ID id, const std::string &path)
{
sf::Texture texture;
if(!texture.loadFromFile(path))
throw std::runtime_error("Could not load: " + path);

sf::Sprite sprite(texture);

drawables.push_back(std::make_tuple(id,texture,sprite));
}

int main()
{
add(ID::Background, "Data/Background.png");

sf::RenderWindow window(sf::VideoMode(500, 500), "Test");
window.setFramerateLimit(60);

while(window.isOpen())
{
window.clear();
window.draw(std::get<2>(drawables[0]));
window.display();
}

return 0;
}

I really don't get why this is not working, I think that the texture or sprite is somewhere copied and not used as a reference but i can not change the vector's tuple arguments to references or pointers because this makes errors :/

4
General / Re: SFML sf::Transform combined transforms
« on: June 23, 2015, 08:41:11 am »
Unless you're counting parents of parents, each child should only really have a single parent. *rereads first post. *realises mParent can only reference a single parent *realises you probably are talking about parents of parents *facepalms

The point here I think is more clear if you think of it in one dimension.
If one object has an absolute position of 10. It's child has a relative position of 20 and it's child has a relative position of 5. The absolute position of the child's child is not 25 (the result of just combining the child's transform and it's parent's), but is 35, as each offset is combined with all of the previous. I may be completely wrong but you did say we may need more code.

A node's transform is always relative to its parent. And the parent node is relative to its own parent. And so on until you reach the root node. So you have to combine the whole chain of transforms up to the root to get the final world transform of a node. Combining the parent's transform only would yield a transform relative to the node's grand-parent.

Ahhhhh of course >< !!

Sry was a stupid question, I realised this now.
Thank you very much! :)

5
General / Re: SFML sf::Transform combined transforms
« on: June 22, 2015, 05:12:04 pm »
Quote
For example our position is (50, 50), position of our parent is (10, 10).
So transform * child-transform is (500, 500).
No. A transform is a matrix, so multiplying two transforms is equivalent to multiplying two matrices, which has nothing to do with multiplying two numbers.

Anyway, you don't have to know the underlying math involved here, just take what the documentation says: multiplying two transforms combines them. In other words, applying transform A * B is equivalent to applying transform A followed by transform B.

To come back to your example, it would be equivalent to a translation of (50, 50) followed by a translation of (10, 10), which is a combined translation of (60, 60).

Ok, I understand this now, thanks.
One question, perhaps you need more information of the code to know this, but why do we want to combine the transformation of our parents?

I mean if we have 10 parents and they have the position (20, 20) the result is (200, 200), so what's the point of that function?

6
General / [SOLVED] SFML sf::Transform combined transforms
« on: June 21, 2015, 08:50:46 pm »
Hello,

i am trying to understand the meaning of

" Overload of binary operator * to combine two transforms. This call is equivalent to calling Transform(left).combine(right). "

but I can't understand this. I am reading the book "SFML Game Development" and I reached this part where I have to wirte this:

HPP FILE:
class SceneNode : public sf::Transformable, public sf::Drawable, private sf::NonCopyable
{
    ...

    private:
        sf::Transform getWorldTransform() const;

        SceneNode *mParent;
       
    ...
};


CPP FILE:
sf::Transform SceneNode::getWorldTransform() const
{
    sf::Transform transform = sf::Transform::Identity;

    for (const SceneNode* node = this; node != nullptr; node = node->mParent)
        transform = node->getTransform() * transform;

    return transform;
}

If a SceneNode is a child, it means it has a parent, we store it in mParent, we have a function which attaches children.
I understand what we are trying to do here, but I don't understand why this for loop should give us the complete transform of the world. We are multiplying our transform with the one our parent has, and if our parent has a parent too, we are multiplying transform with it either and so on. But why should this give us the complete world transform?

For example our position is (50, 50), position of our parent is (10, 10).
So transform * child-transform is (500, 500). Is this our world transform???

I don't get it, I'm sorry, I'm to stupid for that. What is the purpose of '*' operator?


7
General / Qt creator can't find Image.
« on: March 13, 2015, 09:29:13 pm »
Hi,

I wrote this code:

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow sf_window(sf::VideoMode(1280, 720, 32), "Test");
    sf::Event        sf_event;

    sf::Texture sf_texture;
    sf_texture.loadFromFile("Background.png");

    sf::Sprite sf_sprite(sf_texture);

    while(sf_window.isOpen())
    {
        while(sf_window.pollEvent(sf_event))
            if(sf_event.type == sf::Event::Closed)
                sf_window.close();

        sf_window.clear();
        sf_window.draw(sf_sprite);
        sf_window.display();
    }

    return 0;
}
 

I can compile and start the program, it tells me that sfml can’t open the file.
I tested it with g++ on my Linux and it worked perfectly, and because of that I think that I do something wrong with the path of the picture.

The image is in the location of the .pro file (Project file) and i think that qt creator should be able to find it.

8
Also check out this thread: http://en.sfml-dev.org/forums/index.php?topic=12209.0 - lots of great stuff listed there.

Thanks for that Link, and for the 2nd, thats nice too :D

9
I want to create a game and then sell it for a bit pocket money.
But is this posible with SFML or is there a better alternate for SFML?

I dont want to leave SFML because it has graphics, audio, network... and it's easy to use :D , so should I give a try?
Unless you're building a triple-A 3D game for a console, choosing SFML or SDL (or any other established, high level library) won't have much impact on the quality of the game you want to make.

I know, thats just for a bit pocket money ;)

10
SFML.NET 1.5 - http://store.steampowered.com/app/55020/
SFML.NET 1.6 - http://store.steampowered.com/app/55040/

Wow thats nice too, the 2nd game looks entertaining.
Thanks for the links

11
I don't have names right now but there are some SFML games that are on Steam, yes.
Often the devs of these games don't post often around here, so it's impossible to keep track of all of them.

But if you go on the project section you'll find some (indie) games that are sold. I don't know about any AAA game that uses SFML, as they usually use "big" engines like Unity/Unreal/...

Thanks for the Answer.
Ah yes, ok I will check out Steam perhaps i find some of them.

12
I would say that these two qualify:
 http://en.sfml-dev.org/forums/index.php?topic=14614.0
 http://en.sfml-dev.org/forums/index.php?topic=15600.0
and you can find more in that sub-forum.

Thanks for the Links, I see, you can create nice games :D
Thx for that

13
Hello :D,

I just wanted to know if there are good or "professional" SFML games.
Because i searched with Google but online found some hobby games from diffrent hobby programmers.

I want to create a game and then sell it for a bit pocket money.
But is this posible with SFML or is there a better alternate for SFML?

I dont want to leave SFML because it has graphics, audio, network... and it's easy to use :D , so should I give a try?

PS: Sry for my englisch xD

14
General / Re: Codeblocks portable SFML Problem
« on: June 19, 2013, 03:15:51 pm »
snag the 'MinGW TDM GCC 4.7.1 64bit' and redo the tutorial.  Looking at your linker settings you have quite a bit wrong. 

1.  You said you defined SFML_STATIC but you are not linking to the static libraries.  you should be linking to "sfml-graphics-s-d" for STATIC DEBUG and "sfml-graphics-s" for STATIC RELEASE and so forth with the rest.  the Tutorial describes all this if you actually read it and not just look at the pictures.  "sfml-main-d" has no "-s" in it even when statically linking.

2.  your linker setting should look like they do in the tutorial, just "sfml-graphics-s-d", "sfml-window-s-d", "sfml--mainsystem-s-d" and so forth.  you need to get rid of the "..\..\sfml20\lib" and the "  .a" on each entry.

I'm so sorry but i can't fix it  :(

I'm to stupid for that  :-[

I made this Video: http://www.youtube.com/watch?v=opnprXlAJwk&feature=youtu.be

(I made it in HD and tried to make it as professional as I can (JUST FOR YOU MEN))

PLS HELP ME MEN, I'M TO STUPID DO THAT...  :-\

PS: If you don't like the music then switch down the speakers

15
General / Re: Codeblocks portable SFML Problem
« on: June 14, 2013, 07:20:23 am »
You need to grab one of the nightly builds from here http://sfml.my-gate.net/nightly/ for your version.  The build linked off the official site does not work with the current version of code::blocks.

I had this same problem but snagging a new build fixed it.  You could also recomplile SFML from source to work with your code::blocks if you know how.

Could also be Linker settings.

Ok, I go to this Page and there are 5 Kinds of MinGW but which of them do I choose?

I have a 64-Bit Pc and there's only "MinGW TDM GCC 4.7.1 64bit" or
"MinGW-w64 rubenvb GCC 4.7.2 - 64bit" to choose.

I could experiment but I don't want to mess anything up.

Pages: [1] 2
anything