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

Pages: 1 2 3 [4]
46
General / No executable ?
« on: April 16, 2010, 05:06:45 am »
Quote from: "panithadrum"
What compiler are you using? Visual studio?

Make sure you are building an application and not a library. Then, make sure you read the building log. I'm sure there are errors there.


Yeah if its visual studios go to
Project -> Properties -> Config Properties -> General -> Config Type change to Application (.exe)

47
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.

48
General discussions / sf::Ram, sf::Cfg
« on: April 12, 2010, 04:31:38 am »
You should add CPU usage into this.

49
Feature requests / Disable SFML Console Outputting
« on: December 26, 2009, 06:38:12 pm »
Quote from: "Laurent"
SFML outputs to std::cerr, and any standard stream can be redirected to whatever you want: a file, nothing, etc.

You can try this:
Code: [Select]
std::cerr.rdbuf(NULL);

Thanks! That works I didn't even see it used the error stream.

Quote from: "Mr. X"
If you are using Visual Studio just set the Subsystem to Windows. The Console will disappear.

But I want the console :P

50
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

51
General discussions / Build From Source For 2010
« on: December 25, 2009, 12:37:54 am »
I couldn't get the sfml code to build in Visual Studios 2010 Beta 2. However I figured out a way to still use the compiled library from vc2008 librarys. In your project options go to Config Properties -> General -> Platform Toolset -> Set that to V90. Quick work around. Ill have to sit down and setup the project later on.

p.s. Visual Studios 2010 is nice!

52
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

53
Very nice. I was making a GUI class for my own little collection of tools for my games. Although im reworking the core of my own little engine. Keep up the good work.

54
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

55
SFML projects / Squeebs, a 2d comic mmorpg
« on: June 18, 2009, 05:50:38 pm »
Hey Dinocool! I think ive seen the name squeebs before. Was it a gamemaker mmorpg before you wanted to make it in c++?

56
Graphics / Image is white ()
« on: February 02, 2009, 03:00:23 am »
Quote from: "Nexus"
Quote from: "coolhome"
Do I always need to add the * when setting the image? just wondering if there is a way to remove it...

Just return a reference instead of a pointer. ;)
Code: [Select]
sf::Image& ImageManager::Get(const std::string &Key);

wow I feel like a noob now :P

wait I am kind of new to C++ >.< nvm

57
Graphics / Image is white ()
« on: February 01, 2009, 11:49:27 pm »
so im back and this is what i got :P

ImageManager.hpp
Code: [Select]
#pragma once

#include "Includes.hpp"

class ImageManager {
public:
typedef pair<string, sf::Image*> Images;
typedef map<string, sf::Image*> ImagesMap;
ImagesMap manager;
ImageManager();
~ImageManager();
bool Load(const string &Key, const string &Filename);
sf::Image* Get(const string &Key);
};


and ImageManager.cpp
Code: [Select]
#include "Includes.hpp"

ImageManager::ImageManager() {

}

ImageManager::~ImageManager() {
while(manager.begin() != manager.end()) {
delete manager.begin()->second;
manager.erase(manager.begin());
}
}

bool ImageManager::Load(const string &Key, const string &Filename) {
    sf::Image* image = new sf::Image();
    if(! image->LoadFromFile(Filename) ) {
        delete image;
        image = NULL;
return false;
} else {
manager.insert(Images(Key, image));
return true;
}
}

sf::Image* ImageManager::Get(const string &Key) {
sf::Image *resource = NULL;
ImagesMap::iterator it = manager.find(Key);
if(it != manager.end()) {
resource = it->second;
}
return resource;
}


Example:
Code: [Select]
ImageManager manager;
sf::Sprite mouse;
if(! manager.Load("mouse", "mouseGraphic.gif")) {
//error here
}
mouse.SetImage(*manager.Get("mouse"));


Do I always need to add the * when setting the image? just wondering if there is a way to remove it... Also the imagemanager class isn't finished yet >.> got some things to add like checking if the key already exists in the map

58
Graphics / Image is white ()
« on: January 28, 2009, 02:33:20 pm »
Nevermind you can close topic I already solved it I got it...

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

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

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

void loadimage(std::string key, std::string Filename) {
spriteStruct _spriteStruct;
sprites.insert(std::pair<std::string,spriteStruct>(key,_spriteStruct));
sprites[key].Image.LoadFromFile(Filename);
sprites[key].Sprite.SetImage(sprites[key].Image);
}


EDIT: Thanks for that info and I love SFML a lot more then SDL!

59
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 2 3 [4]