SFML community forums
Help => Graphics => Topic started by: Construct on November 12, 2009, 07:23:16 am
-
Hello there, i'm new to sfml :D
Is it possible to create a background image. Then display it and then display another image onto this?
for example:
I create the Background with 64x64 sprites(e.g. small grass sprites)...
//Inside game loop
for(int i=0;i <= 1024;i +=64)
{
for(int j=0;j <= 768;j +=64)
{
sprite.setPosition((float)i,(float)j);
app.draw(sprite);
}
}
This works fine, but when i got a map with a dimension of 36326346x35346346 Pixels (;D) this will cost a lot of time...so i want to create the background at first in a separate sprite/image, then create the foreground image and then display the stuff somehow...but i donno how to add "sprite" into another image/sprite with positioning.
Thought of something like this:
sf::Sprite tile;
//then loading the image etc...
sf::Sprite background;
for(...)
background.Draw(tile,x,y);
//Same with foreground
//Mainloop here
app.Draw(background);
app.Draw(AllNPCsAndStuff);
app.Draw(foregound);
it's similar to the RPGMaker. Backgroundtiles first, then the NPCs and then the foreground tiles.
Hope somebody can help me :>
-
This is not possible in SFML 1.5; SFML 2 provides some options to solve this kind of problems.
-
Even in SFML2 it shouldn't be done like that!
Why don't you just render the stuff that's visible on the screen? There's no need to always draw the whole map.
-
Hi there thanks for your answers :>
Why don't you just render the stuff that's visible on the screen? There's no need to always draw the whole map.
Mhh when it's not possible with sfml 1.5 (where to get 2.0 btw?) I think i should try that.
Ok then i need to think about it. I though I make a whol map image and when moving out of frame just setting the map's position to -X and -Y ( even though i wanted to draw stuff like dead people, blood, dirt etc.. This stuff would dissapear when moving out of screen and back. when i redraw all visible tiles every frame).
-
2.0 is under development and is available from the svn, in the branches directory. (See wiki/forum to know more about svn.)