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

Pages: [1] 2 3 ... 5
1
Graphics / Re: Conversion from SFML angles to radians
« on: June 21, 2014, 09:56:52 pm »
It had been for SFML, but it had one less step than I had thought. It seems it is simply the radian-degree calculation (respective of which direction) along with a negation.

As far as I can tell, it is fixed and working as expected.

2
Graphics / Re: Conversion from SFML angles to radians
« on: June 21, 2014, 06:30:04 pm »
Ah. It seems (I was using a pointed sprite) I mistook an edge of the sprite to be the angle rotation, but it starts upwards.

I made this after finding all of them google made available to me. Some were talks about API changes, but I recall at least two talking about the conversion. Though given the mistake I just realized, it is likely I adapted it wrong.

Conversion functions, basically.

3
Graphics / Conversion from SFML angles to radians [SOLVED]
« on: June 21, 2014, 06:20:29 pm »
Greetings.

When designing things making use of angles - movement, for example - I generally use radians now, as the underlying mechanism, though I may specify initial angles in degrees, as I still find them easier to picture (for example, 1 degree is much more clear to me than the radian equivalent). This works well as the trig functions generally takes radians.

SFML, however, does not.

Due to this, I was trying to convert to and from these different units.

In detail. Radians starting on the positive x axis, counted counterclockwise. SFML degrees, it seems, start on the positive y axis, and are counted clockwise.

I imagine this may be of use to future searches for the same thing.

I seem to have inconsistent success with the functions.

What math would be required for each?

4
Feature requests / Re: float, float for ctors or setSize
« on: January 06, 2014, 09:08:02 pm »
Hrm. Apparently it is easier to find things using google search than the forum search. Now I came up with something.

The reason I found stated was to not have duplicate code, essentially. This is logical. However, I don't see the problem here. setSize(float, float) can call setSize(sf::Vector2f), can it not? I myself did this for something, and have not seen any problems.

ctors can work similarly if using C++11. I don't know when SFML will reach that point, though.

Not sure on the window thing. One place I found said that the window needs to be recreated anyway for such a thing. Another (this by Laurent) said it was a planned feature. I don't think it would be hard to store the flags of the last set, though. Quite possible I am overlooking something obvious.

5
Feature requests / float, float for ctors or setSize
« on: January 06, 2014, 08:40:46 pm »
Greetings. This isn't so much a feature request as an idea for slight convenience.

Let's take RectangleShape as an example, though it isn't the only thing. The ctor takes sf::Vector2f, as does setSize. However, others - position, origin, scale, etc - also take two floats. For lazy people like myself, such methods are nice. Is there a reason the setSize* don't have it?

On another note, I recently added a fullscreen option for something. To check if it was, I had to get the fullscreen modes from VideoMode, then compare it. I feel there must be a better way. Should Window have a getStyle?

6
Network / Re: List of std::pair<sf::TcpSocket, std::mutex>
« on: January 02, 2014, 05:04:37 pm »
I understand the need for dynamic sockets, just not paired mutexes. It sounds like a lot of unneeded work. Just have one mutex lock down the resources so the clients accessing them won't corrupt them.

Imagine there are 100 or more connections. Wouldn't all the waiting start to impact response times? If we are talking about every send and receive. Although I am not certain how this will work if the socket is blocking, unless receive is safe.

7
Network / Re: List of std::pair<sf::TcpSocket, std::mutex>
« on: January 02, 2014, 02:49:07 am »
Why are you dynamically pairing sockets with mutexes?

Why dynamic, or why mutexes? I think I explained why mutexes. As far as dynamic, I don't know how many connections there will be - unlimited, theoretically. Predefined seems rather rigid and more problematic.

8
Network / List of std::pair<sf::TcpSocket, std::mutex> (Solved)
« on: January 01, 2014, 07:24:44 pm »
Greetings. Now, like others, I plan to have a list active connections.

Like others, I ran into the copying problem. To prevent the socket from being copied, I can use a unique_ptr. The problem is, I cannot figure out how to make this work with an std::pair. It needs to be constructed by either moving or copying, and I cannot do either. Currently I was attempting this:

    sockets.push_back(std::make_unique<std::pair<sf::TcpSocket, std::mutex>>(sf::TcpSocket(), std::mutex()));

The mutex was my attempt at making it threadsafe. I plan to, for each client, have a blocking receiver in it's own thread. While this is going on, whenever I want to send a message, I would do it via the same connection. I don't know whether or not that works at the same time.

9
General / Re: Statically linking SFML (Solved)
« on: December 31, 2013, 06:34:30 pm »
Ah. Yup, there is (and related headers).


For future forumgoers (or probably me on my next project when I forget how I did this), you also need to link opengl32.lib. (it has the headers, but not the lib with the rest). Additionally, if you are on windows, also link winmm.lib.

(solved)

10
General / Statically linking SFML (Solved)
« on: December 30, 2013, 11:55:41 pm »
Greetings.

So, since I am terrible at distributing things properly, I was going to try linking statically again (that is, not using DLL's for the standard library, though this also means linking SFML statically).

It seems, though, that a change has occurred, as detailed here:

http://en.sfml-dev.org/forums/index.php?topic=9362.0

As I read it now, you need to link the various dependencies (as listed on the licenses page) when linking statically. Is this correct? Any other needed steps?

If so, is there a prebuilt version of libjpeg somewhere? I am having issues with it, and it's information and documentation seem to be rather outdated.

11
General / Re: Running into seemingly random error in SFML code
« on: October 26, 2013, 12:53:13 am »
I don't know what I am doing either, apparently. I seem to break something ever time I change something, as can be seen by my post history here. Hoping it ends, someday...

I wasn't aware you could successfully build it and still not work, though. Mixing debug and release can break, and that makes sense, but that is not the case here.

12
General / Re: Running into seemingly random error in SFML code
« on: October 25, 2013, 06:20:28 pm »
Still stuck. I tried a fresh rebuild again, but same problems (including an updated Cmake).

I am on a Windows 7 64-bit, but as I have VS Express, and no desired to make 64-bit applications, generated the project as the non-ARM, non-@Win64 one. Was this correct?

I saw you say elsewhere, you plan to make a nightly build for this. Any timeframe on that that you know of?

13
General / Re: Running into seemingly random error in SFML code
« on: October 24, 2013, 04:54:04 pm »
Yes, no, no.

I wrote another example, and... it worked. Apparently the other one was with VS 2012.


14
General / Running into seemingly random error in SFML code
« on: October 24, 2013, 04:41:17 am »
Greetings. So, go back a week ago. I was doing fine using VS 2012 with SFML.

Around this time, I got an odd error: while loading the font, is crashed. This after it had worked for weeks previous. I relinked everything, and it somehow worked.

It got me thinking, though: it would be useful to have the debug files on SFML, so I can step into it, as I would often like to. So, I was going to try building it again, to get said files.

All seemed well, and the pdb files DID work, but... it kept crashing there.

Not making any headway, I switched back. Until today, when I needed some variadic templates, which requires 2013. It gave me the same error while loading the font. I tried rebuilding it again, this time using 2013, with the same result.

It occurs when calling font.loadFromFile. Near the start of that is cleanup(). On the last line of cleanup - clearing the pixel buffer (of size 0), it... breaks.



Yes, this is my fourth attempt at making a snake clone :(. I was searching the memory locations - VS has some magic numbers it marks them with - but didn't find anything.

Any idea of the problem? It was suggested to me to make a minimal working example. In that test (same libraries and everything), it loaded the font fine, but died when I tried to draw it.


15
Graphics / Tilemap drawing breaks with different tile sizes
« on: October 17, 2013, 04:42:14 am »
Greetings. So, I made this little this that renders tiles. It looks like this:



So far, so good. But I wanted to have tiles bigger than 32x32. Or a different size,anyway. This gave me this:



The tree texture is 32x64. It has three leaf tiers: what you see is the top half.

Here is the drawing code:

static sf::Sprite sprite;

        for (int x = 0; x < world.getSize().x; ++x)
                for (int y = 0; y < world.getSize().y; ++y)
                {
                        sprite.setTexture(getTextureForType(world.getFirstLayer(x, y), resource, sf::Vector2i(x, y)));

                        sprite.setPosition(x*32, (target.getSize().y - (y*32 + 32)) - (sprite.getTexture()->getSize().y - 32));

                        target.draw(sprite);
                }

        for (int x = 0; x < world.getSize().x; ++x)
                for (int y = 0; y < world.getSize().y; ++y)
                {
                        sprite.setTexture(getTextureForType(world.getSecondLayer(x, y), resource, sf::Vector2i(x, y)));

                        sprite.setPosition(x*32, (target.getSize().y - (y*32 + 32)) - (sprite.getTexture()->getSize().y - 32));

                        target.draw(sprite);
                }

The first layer is things like the ground, second is trees, etc.

But, if I comment the first loop, I get this:



When I, between the loops, add:

    sprite.setTextureRect(sf::IntRect(0, 0, 32, 64));

I get this:



Note this is drawn multiple times, which is why (presumably) the ground is distorted like that.

What is going on here? I cannot figure it out. Also, I reverse the y coordinates of the tiles, so when generating, y + 1 is up the screen, not down.

A while back, I saw a thread stating that sprites are not a drawing tool. For example, a sprite should always be a spaceship, not switching between tiles. If need be, I can try that (one sprite per tile), but I am still curious.

Or perhaps a tilesheet, but I am yet to discover a good way to load them easily, and editing them in the past didn't work well for me.


EDIT: I was checking SFML's source, and apparently setTexture has a parameter to reset the rectangle. When I pass true for this, it seems to work correctly.

I am still interested in best practice for tilemaps, though.

Pages: [1] 2 3 ... 5