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 - Dark Goomba

Pages: [1]
1
Graphics / Re: Tile map to image for color masking/transparent tiles
« on: June 26, 2014, 06:47:22 am »
Load your tile map to an image then copy it to a texture with this code:
        sf::Image ImageTileMap;
        sf::Texture TileMap;
        ImageTileMap.loadFromFile("filename");
        ImageTileMap.createMaskFromColor(...);
        TileMap.update(ImageTileMap);
or you can always convert sf::Texture to sf::Image with
image = texture.copyToImage()
Afterwards, create your tile map class using your texture.

2
General / Re: #include Puzzle
« on: June 22, 2014, 03:51:28 am »
Yes, all of the guard tags are properly used and the header files are self contained. I am just unsure which files should include what.

Edit: I tried the forward declarations and IT WORKED! Thanks everyone.  :)

3
General / #include Puzzle
« on: June 21, 2014, 07:07:42 am »
Hi everyone. I am working on a game that has a lot of files. The problem is that I don't think that I am including the header files in the right sequence, so some of the classes are undefined. The files are Battlefield.h, Creature.h, Enemy.h, Button.h. I've spent hours trying to code it so:

Battlefield.h  has Creature.h, Enemy.h, and Button.h defined.
Creature.h    has Enemy.h and Battlefield.h defined.
Enemy.h       has Creature.h and Battlefield.h defined.
Button.h       has Creature.h and Battlefield.h defined.

Thanks in advance.

4
It looks like it should work but you could try putting the real time keyboard event in the poll event loop:
while (Window.pollEvent(Event))
{
     if (sf::Keyboard::isKeyPressed(sf::Keyboard::Z))
          std::cout << "Z" << std::endl;
}

5
General / Re: Probleme with a SpriteManager
« on: May 24, 2014, 01:54:22 am »
There is actually another way to use the sprite manager. You don't need to store the sprites in dynamic memory, instead, create two vectors, one for sprites and one for textures. Try this code:
Code: [Select]
bool SpriteManager::AddSprite(const std::string file)
{
sf::Texture tex;
if (tex.loadFromFile(file))
{
sf::Sprite spr;
TextureIndex.push_back(tex);
spr.setTexture(TextureIndex[TextureIndex.size()-1]);
SpriteTexture.push_back(spr);
return true;
}
return false;
}
If you need, you can always delete the sprites but remember to delete the texture too.

6
Graphics / Organizing Code with Load Texture
« on: March 22, 2014, 10:15:54 pm »
Hello everyone.
I am still a beginner on sfml. But I was wondering if there's a way to separate all the messy texture.loadFromFile("picture") with the rest of the code. Because Main.cpp is getting overloaded with this:

     sf::Texture texGoomba;
     sf::Sprite sprGoomba;
     if (!texGoomba.loadFromFile("goomba.png"))
          std::cout << "Error: goomba.png could not load" << std::endl;
     sprGoomba.setTexture(texGoomba);
     sprGoomba.setPosition(0,0);

So I tried putting all of that on to resource.cpp as a static member function,

     //resource.cpp
     void CResource::loadGoomba()
     {
          sf::Texture texGoomba;
          ...
     }

Though it's loaded on resource.cpp, main.cpp doesn't seem to recognize sprGoomba.
Well, if there's any better way to do this, any help would be appreciated.

7
General / Re: Setting up SFML
« on: January 29, 2014, 04:40:00 am »
Ok, I spent some time to check everything. The working directory is set to the same location as the project file. The picture name is spelled right, it is a png, and it's in the correct location. I'm not sure what I did wrong.

Edit: Solved!! I called the picture "Picture.png" and I changed it to just "Picture" and it worked! Well anyways, thanks to everyone above for the useful info on working directories!  ;)

8
General / Re: Setting up SFML
« on: January 28, 2014, 05:12:36 am »
Thanks for the help.
I was using sf::Texture, Texture.loadFromFile() but it seemed to not work. So I guess the installation wasn't the cause in this case. Anyways, I put Picture.png in the same folder as main.cpp but it displayed this: "Failed to load image "Picture.png" Reason : Unable to open file" Is there any way to fix this?

9
General / Setting up SFML
« on: January 28, 2014, 04:36:20 am »
Hello everyone!

I'm quite new to sfml 2.1 but I can't manage to even pass the first step: the set up. I went through the installation instructions almost ten times but when I run my program on visual studio 2010 I get these warnings:

C:\...\NewProject\Debug\sfml-system-d-2.dll', Cannot find or open the PDB file
C:\...\NewProject\Debug\sfml-window-d-2.dll', Cannot find or open the PDB file
C:\...\NewProject\Debug\sfml-network-d-2.dll', Cannot find or open the PDB file
C:\...\NewProject\Debug\sfml-graphics-d-2.dll', Cannot find or open the PDB file
C:\...\NewProject\Debug\sfml-audio-d-2.dll', Cannot find or open the PDB file

I put my working directory to C:\...\NewProject\Debug so I thought that might work but it didn't.
I know there's probably something I did wrong or I'm just bad with dlls
Either way, any help is appreciated! :)

Pages: [1]
anything