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.


Topics - coolhome

Pages: [1]
1
General / CMake & MSVC & SFML 2 Static Issue
« on: January 31, 2012, 08:25:08 am »
Hello everyone!

I just noticed that I cannot compile SFML 2.0 (latest git version) as a static library. I unchecked BUILD_SHARED_LIBS and it compiles the dll's. I have tried this multiple times. Can anyone else confirm this behavior?

I'm digging into the CMake files to see if I can find the problem.

2
General discussions / [IDEA] Move sf::Rect into System Module?
« on: August 22, 2011, 05:25:47 am »
Hello SFML Community!

I was looking over the library and every time I use sf::Rect I always include the system module. However I always forget its in the Graphics Module. Wouldn't it make more sense to put it in the systems module? Just an idea. Nothing to important. Just in my opinion I think it would have a better home in the system module.

-coolhome

3
General discussions / Window drag keep rendering (solution) [SFML 2.0]
« on: August 01, 2011, 04:26:59 pm »
Hello there! After doing research on why the SFML window is paused when you dragged I think I found a decent solution. It works on windows, maybe linux. I don't think it will on mac tho. Anyways I just wanted to see what you guys thought of this code I wrote up.

If you were to use this, I'd recommended creating a thread safe event manager to pass the events on into the other thread.

Code: [Select]

#include <iostream>
#include <math.h>
#include <SFML/Graphics.hpp>


void GameThread(sf::RenderWindow *window)
{
window->SetFramerateLimit(60);
sf::Image sfmlLogo;
sfmlLogo.LoadFromFile("HaikarainenSFMLLogo.png");
sfmlLogo.SetSmooth(true);

sf::Sprite sprLogo;
sprLogo.SetImage(sfmlLogo);
sprLogo.SetOrigin(floor(sfmlLogo.GetWidth() / 2.f), floor(sfmlLogo.GetHeight() / 2.f));
sprLogo.SetPosition(400,300);

while (window->IsOpened())
{
sprLogo.Rotate(0.5f);

window->Clear();
window->Draw(sprLogo);
window->Display();
}
}

int main()
{
sf::RenderWindow window;
sf::Thread gameThread(&GameThread, &window);
sf::Event event;

window.Create(sf::VideoMode(800,600,32), "Test");
window.SetActive(false);

gameThread.Launch();

while(window.WaitEvent(event))
{
if (event.Type == sf::Event::Closed)
{
window.Close();
}
}

gameThread.Wait();

return EXIT_SUCCESS;
}


Party on,
Preston Alvarado

p.s. I didn't know where to post this to be honest. This forum category seemed good enough.

4
Feature requests / [Request] sf::Sprite Flip Methods
« on: March 21, 2011, 11:43:59 pm »
Hello everyone,

After using SFML for a while now I realized the sf::Sprite::FlipX and FlipY doesn't really fit in with the rest of the sprite class. All of the other methods are mainly Get and Set. I think we should do a SetFlipX, SetFlipY, SetFlip (X + Y). Also add a GetFlipX and GetFlipY.

Also I don't know if this would be something else to add but when you flip a image also flip the origin with it. Maybe make that another method,,, I don't know lol

5
Graphics / sf::Sprite / sf::Image pointer...
« on: April 16, 2010, 04:39:35 am »
Hello.  Okay so let me just explain my class setup real quick.

Screen with a virtual Destruct, Construct, Draw, Update functions. (Please not the function Destruct and Construct are not Screen() and ~Screen() and are implemented.)
Screen also has SetBase(Engine *base); to get the base functions.

ScreenManager which has a map of screen pointers. Screens are added for e.g.
sm->AddScreen("menu", new MenuScreen()); //ScreenManager also deletes them...

ImageManager which creates and deletes sf::Image.

So the engine dynamically loads image manager then screen manager.

So for example if my class Engine destruct deletes ImageManager then ScreenManager it all works fine. But if i do it the other way because it seems more logical I get a memory heap. I think ive pin pointed it down to sf::Sprite in MenuScreen. It uses a pointer from the image manager but nothing else is called (or is it...). So to remove this heap i have to

background = sf::Sprite();

Any suggestions? Im guessing it has to do with image pointers...

p.s. Sorry if you don't understand this i can post code if needed to help. Me translating code in English isn't that well lol.

6
Feature requests / Disable SFML Console Outputting
« on: December 26, 2009, 04:18:57 am »
The title basically says it. I think this would be cool to have. If this is an option already please tell me because somehow I missed it big time.

Thanks,
Preston

7
Graphics / Creating transition?
« on: November 16, 2009, 12:29:36 am »
Hello,
Ive been wondering for a long time now that if you create a screen system how would you even start to create a transition?

Any ideas or suggestions?

Thanks,
Preston

8
General / Sprite Rotation + Collision Check = Question
« on: July 17, 2009, 04:55:14 am »
Hello. I got a question that I've ran into in my game development. Lets say we have a object thats 200x100. We set the center to the exact middle and rotate it. Now when we check if the player box intersects with the odd rotating shape how do we do that correctly?

Sinces its rotating sf::IntRect doesn't have a rotate feature.

or am I completey wrong and off track here :P

Thanks,
Preston Alvarado

9
Graphics / Image is white ()
« on: January 28, 2009, 02:15:47 pm »
ok first just let me dump my code =)

Code: [Select]
struct sprite {
sf::Image Image;
sf::Sprite Sprite;
int x;
int y;
float rotation;
sf::IntRect SubRect;
};

typedef std::pair<std::string, sprite> value_type;

std::map<std::string, sprite> sprites;
std::map<std::string, sprite>::iterator spritesIterator;

void loadimage(std::string key, std::string Filename) {
sprite _spriteStruct;
sf::Image _load;
sf::Sprite _sprite;
if(! _load.LoadFromFile(Filename)) {
//error
}
_spriteStruct.Image = _load;
_spriteStruct.Sprite = _sprite;
_spriteStruct.Sprite.SetImage(_spriteStruct.Image);
sprites.insert(std::pair<std::string,sprite>(key,_spriteStruct));
}


Ok well i understand this
Quote
You have to be particularly careful when manipulating images. A sf::Image instance is a resource which is slow to load, heavy to copy and uses a lot of memory.

A lot of people, especially beginners, will just put an instance of sf::Image wherever they have an instance of sf::Sprite, because it may seem the simplest way to draw something. The fact is that it's generally a bad idea. The most obvious problem is when copying such objects (just putting them into an array generates copies) : the sprites will most likely appear white. The reason is that a sprite only points to an external image it doesn't own one, so when the image is copied the sprite has to be updated to point to the new copy of the image. This is quite easy to handle, you just have to define a copy constructor for such classes holding (or deriving from) a sprite and an image

but i dont understand exactly what im doing wrong...[/code]

Pages: [1]