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

Pages: 1 [2] 3
Graphics / Re: Loading a map of a file
« on: July 09, 2012, 10:42:25 pm »
Okay well then open the text file and using a for loop, cycle through each line. Save one line at a time inside of a std::string and then us another for loop to go character by character and, depending on the character, save a specific image into a vector.

for (int row = 0; file.good(); ++row) {
    std::string line;
    getline(file, line);
    for (int col = 0; col < line.length(); ++col) {
        if (line[col] == '1') {
            // save image for ID of 1
        // .... so on and so forth

Graphics / Re: Loading a map of a file
« on: July 09, 2012, 10:19:57 pm »
If you are trying to do this for a game you are making, and you don't care if EVERYTHING is made by your fingers, I would suggest making your maps with Tiled Map Editor (http://www.mapeditor.org/).
It is extremely easy to use and their is a library that loads the map directly into your program. All you have to do is change that information into SFML Textures and Sprites.
TMXParser (http://code.google.com/p/tmx-parser/)

SFML projects / Re: Thor 2.0
« on: July 09, 2012, 06:57:09 pm »
Oh okay, that makes sense.
Thanks! Have you considered opening a forum for Thor? It would make finding questions that have already been asked sooooo much easier.

EDIT: I have a question about the thor::Action system. I put a thor::ActionMap in a class and I can't get it to work as a pointer.
class MyClass
    MyClass(sf::RenderWindow* window) {
        map = new thor::ActionMap<UserActions>(*window); // This work with no error
        map[Action1] = thor::Action(sf::Keyboard::A); // This gives me an error with the operator=.
        // Unmatched types. Is there a workaround?

    thor::ActionMap<UserActions>* map;

Graphics / Re: Help with arrays, and crashing (RPG inventory system)
« on: July 09, 2012, 06:51:52 pm »
Oh Lord, I don't know, man. Have you considered organizing your code better? i.e. classes, multiple files, etc.

Graphics / Re: Help with arrays, and crashing (RPG inventory system)
« on: July 09, 2012, 06:00:03 am »
Hmmmm.... I don't know what the problem is that you are having, but I do know that you need to put a catcher in your delItem function. The selectInv variable gets set to -1 at some point in there and if no item is selected, but the user hits 'DISPOSE' the program will crash from what I see. -1 is an invalid position in the array.
if (cursor_box.intersects(buttonDispose_box)) // if they click DISPOSE after selecting an item
        std::cout<<"DISPOSE THIS ITEM"<<std::endl; // for testing
        selectInv = -1; // reset selectInv

Perhaps like so...
void delItem(int selectInv) // selectInv is a number 0-95 and is decided from the functions above (when the player clicks in a space)
    if (selectInv >= 0) {
        sf::Texture invEmpty;
        textureArray[selectInv] = invEmpty; // a blank 5x5 png texture

On another note.
Could you send me the full code? I'll see if I can figure out what could be causing that.

SFML projects / Re: Thor 2.0
« on: July 09, 2012, 05:43:22 am »
I'm new to Thor and I love what I see so far. I'm trying to wrap my head around the resource manager though. I think I'm beginning to understand how it works, but I have a question.

Would you think it would be better to make a ResourceSystem class with one ResourceCache inside of it to load ALL of the resources throughout the program? Or... Would it be better to have every thing that needs a resource have a ResourceCache and load it's own resources?

Graphics / Re: Animation Library
« on: July 06, 2012, 08:21:05 pm »
Okay thanks.

Graphics / Re: Animation Library
« on: July 06, 2012, 08:03:34 pm »
Oh wow. Thor looks like its awesome. Many useful features. Is 2.0 close to release or should I just go ahead and get 1.1?

Graphics / Animation Library
« on: July 06, 2012, 07:42:08 pm »
I've seen many animation libraries on this site and made with SFML, but I do not know what exactly to look for in an animation library. Any suggestions?

Graphics / Re: Divide By Zero When Drawing
« on: July 05, 2012, 09:22:58 pm »
I do know what a pointer is... -__-
I don't, however, claim to know everything.

Thanks for the fix.

Graphics / Re: Divide By Zero When Drawing
« on: July 05, 2012, 08:58:21 pm »
void Tile::AddTexture(sf::Texture* _texture) {

How do I copy the texture rather than the pointer?

Graphics / Re: Divide By Zero When Drawing
« on: July 05, 2012, 07:47:03 pm »
Oh wow! I found it.
tiles.back()->AddTexture(tile_texture); delete tile_texture;
I just don't understand why. I transferred the texture into the Tile object...

Graphics / Re: Divide By Zero When Drawing
« on: July 05, 2012, 07:34:58 pm »
Oh Lord! Thank God for you guys. I tried your texture size thing and the sizes come up in the millions and then some are 0. I checked the validity of the sprite, but it didn't occur to me to check the texture.

I just don't see when I went wrong with the loading of the texture. I can't get my minimal to reproduce the problem. It keeps working. XD

// Load the tileset into memory
sf::Image* tileset_image = new sf::Image;

// Create a temporary image to manipulate
sf::Image *tile_image = new sf::Image;
tile_image->create((int)tile_dimensions.x, (int)tile_dimensions.y);
// Copy the tile image into the sf::Image
tile_image->copy(*tileset_image, 0, 0,
        sf::IntRect(tileset->GetMargin() + (col - 1) * tileset->GetSpacing() + (col - 1) * tileset->GetTileWidth(),
        tileset->GetMargin() + (row - 1) * tileset->GetSpacing() + (row - 1) * tileset->GetTileHeight(),
        tileset->GetMargin() + col * tileset->GetSpacing() + col * tileset->GetTileWidth(),
        tileset->GetMargin() + row * tileset->GetSpacing() + row * tileset->GetTileHeight()));

// Create a temporary texture to prepare for loading
sf::Texture *tile_texture = new sf::Texture;
// Load image into texture
tile_texture->loadFromImage(*tile_image); delete tile_image;
// Add texture into the texture
tiles.back()->AddTexture(tile_texture); delete tile_texture;
delete tileset_image;

This is a small portion of the code for loading textures from the sprite sheet. The original that presents problems.

Graphics / Re: Divide By Zero When Drawing
« on: July 05, 2012, 06:25:08 pm »
Smart Alec. XD

I'll post up a minimal code of the algorithm I used. :)

Graphics / Re: Divide By Zero When Drawing
« on: July 05, 2012, 05:17:49 pm »
I'm pretty sure it is. I don't see anything that could be wrong with the algorithm that pulls the texture from the sprite sheet. The algorithm worked in 1.6, all I did was port it by changing things to sf::Image and sf::Texture appropriately. Maybe I don't adequately understand how to use each one and how each one is related to the other.

Pages: 1 [2] 3