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

Pages: [1] 2
1
Yea thank you.  I was doing a search and found that.  Seems like it would be useful if you had a method on window class to get the client rect, for other programming problems. 

2
I found that Mouse::getPosition() returns window space, you can subtract window.getPosition() but its off by the boarders of the window I think.  How to get this right?

3
Can soeone just give me a pointer on what to do tho solve this??

LearnCPP * pLearnCPP = new LearnCPP();

Here you go.  Don't forget to delete it when you're done.

4
Graphics / Re: SFML2 nightly how to flip a Sprites Texture?
« on: January 04, 2013, 03:07:31 am »
Quote
This doesn't appear to work, I just get the streaks for an image, where the pixels are the same as the first one across the entire image.
Are you sure that you used sf::IntRect(0, height, width, -height) and not sf::IntRect(0, 0, width, -height)?
Yea this seems to work!  Much better solution thank you.

5
Graphics / Re: SFML2 nightly how to flip a Sprites Texture?
« on: January 03, 2013, 08:39:25 am »
Thank you for your replies.  In case anyone has a simular issue I'll post a solution I found. 

It isn't ideal from a memory standpoint but it does work.  Load your image as an sf::Image
then flip it using the method, and then load it into a texture.  Texture will copy it into a field.

sf::Image upsideDownImage;
   upsideDownImage.loadFromFile( "someImageFile.jpg" );
   upsideDownImage.flipVertically();

   mBackgroundTexUpsideDown.loadFromImage( upsideDown );

So this means you have to have 2 images in memory, even though they are the same image just flipped.  And also flip and copy operations that take some time.  You don't have to keep the original sf::Image around since sf::Texture copies it into a field.

Granted that's a good solution, but impractical in a real-time implementation as texture binding isn't something trivial timewise. There shouldn't be much of a memory issue with it unless the image is big. If you need to use the flipped ones often you can just add the images (assuming it's for an animation and that it doesn't exceed too much in size) in the sprite sheet.

It's only done during the loading, not during the real time loop so performance isn't effected just load times slightly.

6
Graphics / Re: SFML2 nightly how to flip a Sprites Texture?
« on: January 02, 2013, 03:49:16 am »
Negative scale should work, but it moves the sprite.

The only solution that doesn't touch the sprite's transformation at all, is to use a textureRect with a negative height (sf::IntRect(0, height, width, -height)).

This doesn't appear to work, I just get the streaks for an image, where the pixels are the same as the first one across the entire image.

7
Graphics / Re: SFML2 nightly how to flip a Sprites Texture?
« on: January 02, 2013, 03:40:12 am »
Thank you for your replies.  In case anyone has a simular issue I'll post a solution I found. 

It isn't ideal from a memory standpoint but it does work.  Load your image as an sf::Image
then flip it using the method, and then load it into a texture.  Texture will copy it into a field.

sf::Image upsideDownImage;
   upsideDownImage.loadFromFile( "someImageFile.jpg" );
   upsideDownImage.flipVertically();

   mBackgroundTexUpsideDown.loadFromImage( upsideDown );

So this means you have to have 2 images in memory, even though they are the same image just flipped.  And also flip and copy operations that take some time.  You don't have to keep the original sf::Image around since sf::Texture copies it into a field.

8
Graphics / Re: SFML2 nightly how to flip a Sprites Texture?
« on: December 29, 2012, 01:47:12 am »
hmm I tried what you said, but now there is just black where the texture should be, I think this is because it's drawing it up and to the right, instead of down and to the right.

9
Graphics / SFML2 nightly how to flip a Sprites Texture?
« on: December 29, 2012, 01:07:38 am »
What is the proper way to flip a sprites texture without moving the sprite?

I have a single texture, and two sprites that reference it.

I want one of these sprites to display the texture flipped.  This is so it looks like they connect when placed together.

Edit I mean flipped on the Y axis.

10
General / Re: Iterating through a list of pointers
« on: December 24, 2012, 06:27:58 pm »
How about some good hard facts to set the record straight.  This article was featured on isocpp.org

http://www.baptiste-wicht.com/2012/11/cpp-benchmark-vector-vs-list/

11
Guess that means I should use pointers for the Sprites to, just to be safe.
No you don't have to use smart pointers for the sprites. They are a light-weighted class and as long as the address of the referenced texture doesn't change, everything should be fine.

The reason why you should use smart pointers for sf::Texture and sf::Sound, is because they are resources which others depend on, so a simple address change isn't nice, since they get already referenced by other objects. ;)

Are you confusing sf::Sound with sf::SoundBuffer ?  I replaced sf::Sound using a smart pointer and it did fix my issue even though it isn't the buffer like sf::SoundBuffer and sf::Texture are.  Unless I am mistaken?

12
I did what you said made them unique_ptr's now it seems to work fine, hasn't hiccuped yet.  Guess that means I should use pointers for the Sprites to, just to be safe.

13
General / Re: Iterating through a list of pointers
« on: December 23, 2012, 11:54:50 pm »
Why a list?  vector would be much better in this situation.

14
Is it safe to use the classes that you use to instance things like Sound and Sprite?  Of course you don't want to with the Texture and SoundBuffer classes.

I am using them in std::vector and I know that from time to time vector will move them around, and when I want to erase one, i swap it with the last one then pop_back() the last one, is this going to cause trouble?

Second issue that maybe related to the first.

I have a std::vector<Sound>, when ever i want to play a new sound like a laser shot, i create a Sound and use the laser sound buffer to construct the sound.  Then I call push back it into the vector and then use back().play().

I a loop to check the status and if the status of one of these sounds is stopped then I swap it with the last one then pop_back() to remove it. 

However occasionally one of the sounds doesn't play when it should and sometimes one seems to get cut off.  Is the use of vector messing them up or something else my problem?

15
General discussions / SFML 2.0 nightly is very good.
« on: December 22, 2012, 05:48:42 am »
I've just picked up SFML today for the first time, with barely glancing at the docs I was able to get a working space invaders prototype game done in a day.  Using the Dec 17th nightly for VS11.  Everything was right where I expected it to be in the OOP style, and everything I did worked great and was very easy to work with.  Thank you for the hard work that has gone into this, and the free, even for commercial license!   ;)

Pages: [1] 2
anything