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

Pages: 1 2 [3] 4
31
General / How to debugging
« on: May 13, 2012, 12:02:48 pm »
Hi guys, i tried debugging and this is what i get:

Code: [Select]
The thread 'Win32 Thread' (0x674) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x22c) has exited with code 0 (0x0).
The program '[2308] LegendsReborn.exe: Native' has exited with code 0 (0x0).

Can anyone tell me what it means ?

32
General discussions / Can someone make a tile system tutorial ?
« on: May 12, 2012, 07:11:41 pm »
Hi guys, i was desperatly trying to learn sfml, and i learned a lot but i still cant create a good tile system engine that loads maps from xml files.
Will anyone be kind to make me one ?

Im using SFML 2.0 RC, since 1.6 seems bad

p.s. a tutorial section would be cool

33
Im building a debug. Im using custom fonts.

34
Graphics / Problem with tile system
« on: May 12, 2012, 11:29:45 am »
Hi guys, im trying to load a map with rapidxml, it compiles alright but when i call the function , i get a error.

Here is the code:

Code: [Select]
void LoadMap(std::string mapname, Block *blocks[] )
{
//Loads a level from xml file
//Load the file
std::ifstream mapFile(mapname);

if(!mapFile)
throw "Could not load tileset: " + mapname;

//Dump contents of file into a string
std::string xmlContents;

//Blocked out of preference
{
std::string line;
while(std::getline(mapFile, line))
xmlContents += line;
}

//Convert string to rapidxml readable char*
std::vector<char> xmlData = std::vector<char>(xmlContents.begin(), xmlContents.end());
    xmlData.push_back('\0');

//Create a parsed document with &xmlData[0] which is the char*
rapidxml::xml_document<> doc;
doc.parse<rapidxml::parse_no_data_nodes>(&xmlData[0]);

//Get the root node
rapidxml::xml_node<>* root = doc.first_node();

std::string imagepath;

//Load each necessary tileset
rapidxml::xml_node<>* tileset = root->first_node("tileset");
while(tileset)
{
imagepath = tileset->first_attribute("name")->value();
}
sf::Texture texture;
texture.loadFromFile(imagepath);

//Columns and rows (of tileset image)
    int columns = texture.getSize().x / 32;
    int rows = texture.getSize().y / 32;

std::vector <sf::Rect<int> > subRects;
    for (int y = 0; y < rows; y++)
    {
        for (int x = 0; x < columns; x++)
        {
            sf::Rect <int> rect;
            rect.top = y * 32;
            rect.height = y * 32 + 32;
            rect.left = x * 32;
            rect.width = x * 32 + 32;
            subRects.push_back(rect);
        }
    }
rapidxml::xml_node<>* tile = root->first_node("tile");
int block_type = -1;
int x = 0;
int y = 0;
int n = 0;

while(tile)
{
block_type = atoi(tile->first_attribute("gid")->value());

blocks[n] = new Block( n, block_type, x, y);

x += 32;

cout<<"ID: "<<n<<" Block type: "<<block_type<<" X,Y: "<<x<<","<<y;

        if( x >= SCREEN_WIDTH)
        {
            x = 0;
            y += 32;
        }

n++;
tile = tile->next_sibling("tile");
}
mapFile.close();
}

This is how i call it:

Block* blocks[TOTAL_TILES];
LoadMap("spawn.tmx", blocks);

Debug error: R6010
-abort() has been called

and i can only click abort, retry and ignore

35
oh yeh thats copy paste error, i was writing it manually

Code: [Select]

while (App.isOpen())
{
while (App.pollEvent(Event))
{
if (Event.type == sf::Event::Closed)
App.close();
                        if (Event.type == sf::Event::KeyReleased)
{
if(Event.key.code == sf::Keyboard::Return)
{
if(stage == 0)
{
stage = 1;
loaded = 0;
}
else if(stage == 1)
{
if(menu_choice == 0)
{
stage = 2;
loaded = 0;
}
if(menu_choice == 1)
{

}
if(menu_choice == 2) // This is when he presses exit menu/same goes for the X  sign on the windows bar.
{
App.close();
}
}
}
                        }
}
        }

    return EXIT_SUCCESS;
}

thats it

Im using windows 7, VC++ 2010. Hes still on Win XP SP3.

Im gonna try giving him an empty window program, to see if it works with that one.

36
What ? No i doesnt close since you can write one command after "if" and it will be considered like its in the brackets. Thats not the problem. It runs perfectly on my pc, but on his when he presses exit he gets that error.

37
this is what he gets:
Code: [Select]
the instruction at "0x004f53cc" referenced memory at "0x027581c8". The memory could not be "read". Click on OK to terminate the program
But i close it, it closes normally

while (App.isOpen())
        {
                while (App.pollEvent(Event))
                {
                        if (Event.type == sf::Event::Closed)
                                App.close();
                }
                return 0;
         }
 

38
Graphics / Re: Switching from image to textures.
« on: May 09, 2012, 04:44:25 pm »
Oh loading once big pic into a texture and then splitting it into sprites is pretty logical.

argh, im such a noob :D need to learn classes and arrays to make it properly-

Laurent, is this
http://en.sfml-dev.org/forums/index.php?topic=3023.0
system good ? I will jsut edit it for sfml 2,0

39
Graphics / Re: Switching from image to textures.
« on: May 09, 2012, 04:20:24 pm »
Ups, i edited the message and removed it.

Yes, im loading a big one and then cliping it.

40
Graphics / Re: Switching from image to textures.
« on: May 09, 2012, 04:02:11 pm »
Everything works properly if i comment:
tileTexture.update(tileset, 0, 0);

right now the code is:

sf::Texture tileTexture;
tileTexture.create(tileSize, tileSize);
tileTexture.loadFromImage(tileset, sf::IntRect(x * tileSize, y * tileSize, frames * tileSize, tileSize));
 


41
Graphics / Re: Switching from image to textures.
« on: May 09, 2012, 03:04:36 pm »
I think i did what you said in your second option right ?

Create a new texture and load the image inside it.

42
Graphics / Switching from image to textures.
« on: May 09, 2012, 02:17:12 pm »
I want to load a  texture onto a texture. (before i loaded a image and a image with copy)

or should i can i make image onto a texture ? which is better ?
btw this is my TextureManager.cpp (changed from ImageManager.cpp)


I used to have:

sf::Image tileset;
sf::Image tileImage;
tileImage.Copy(tileset, 0, 0, sf::IntRect(x * tileSize, y * tileSize, frames * tileSize, tileSize), true);

But now i switched my code all to sfml 2.0 and i dont know the function that copies in sfml 2.0.

i want something like this:
sf::Image tileset;
sf::Texture tileTexture;
tileTexture.Copy(tileset, 0, 0, sf::IntRect(x * tileSize, y * tileSize, frames * tileSize, tileSize), true);

edit:

I searched a bit, and i think i could use loadFromImage but im not sure how. An example with the code above would be appriciated.

edit2:

Maybe this ? but im lacking the 0,0 position, maybe texture.update ?
tileTexture.loadFromImage(tileset, sf::IntRect(x * tileSize, y * tileSize, frames * tileSize, tileSize));
 

edit3:

I managed to fix the errors. Can someone tell if this code does like the past one ?

sf::Image tileset;

sf::Texture tileTexture;
tileTexture.create(tileSize, tileSize);
tileTexture.loadFromImage(tileset, sf::IntRect(x * tileSize, y * tileSize, frames * tileSize, tileSize));
tileTexture.update(tileset, 0, 0);
 

I have the correct tileSize declaration. i dont get any errors when compile.

ty

43
Graphics / Real time input, input box
« on: May 08, 2012, 11:16:09 pm »
I want to write out the text as something types it on the keyboard. So basically a input box without the box  :o

Is there any function like GetPressedKey() ????

44
Thanks for pointing the fact that it overwrites. I rewritten my code from scratch and now it seems to be working alright. I think it was a problem that i made some declarations inside a class that should be inside   ;D

45
Graphics / sf::Text Same variable for many uses ? How to unload ?
« on: May 08, 2012, 05:10:20 pm »
So at the beginning i made sf::Text and set the string to example1. Then i changed the position and the string to example2. But when i do App.Display() i get both. Do i have to make a new sf::Text, or can i somehow unload the example1.

Does making a new variable impact my code in the long run ? (if i continue making new sf::Text for every text)

Pages: 1 2 [3] 4
anything