Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Tile Engine  (Read 4042 times)

0 Members and 1 Guest are viewing this topic.

deathsangel

  • Newbie
  • *
  • Posts: 2
    • View Profile
Tile Engine
« on: April 29, 2009, 05:29:55 am »
Can somebody tell me how one would approach making a tile engine.
I used to use sdl so im used to being to just blit a surface.
Is this possible in sfml if so how do you do it?

example code from sdl
Code: [Select]

for (int r = 0; r < rows; r++)
{
    for (int c = 0; c < columns; c++)
    {
          SDL_Rect rect = {c * tileWidth, r * tileHeight, tileWidth, tileHeight}
         
          switch(map[r][c])
          {
                case 0:
                     break;
                case 1:
                     SDL_BlitSurface(tileImage, NULL, screen, &rect);
                      break;
          }
    }

}

So pretty much is it possible to recreate something similar in sfml.  Or if not what should I do?[/code]

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Tile Engine
« Reply #1 on: April 29, 2009, 01:24:25 pm »
with an image manager (there is one on my wiki), and a set of sprite (eg a std::vector).

Isn't there already one tile engine on the official wiki ?
SFML / OS X developer

SamuraiCrow

  • Newbie
  • *
  • Posts: 40
    • Yahoo Instant Messenger - samuraileumas
    • View Profile
Tile Engine
« Reply #2 on: April 30, 2009, 06:08:48 pm »
There is this resource manager on the official Wiki.  Also, in SFML 2.0 there is planned to be a batch-rendering mode that will improve the performace of tile maps.

SamuraiCrow

  • Newbie
  • *
  • Posts: 40
    • Yahoo Instant Messenger - samuraileumas
    • View Profile
Tile Engine
« Reply #3 on: April 30, 2009, 06:36:34 pm »
After thinking about it for a while, you could use the sf::view class to scroll around a bunch of sf::sprite objects placed at absolute coordinates.  That way you wouldn't have to calculate which tiles are visible and which tiles are not.

csiz

  • Newbie
  • *
  • Posts: 30
    • Yahoo Instant Messenger - calinutzu92
    • View Profile
    • Email
Tile Engine
« Reply #4 on: April 30, 2009, 09:39:24 pm »
what is batch rendering? I couldn't find on google :(

edit:I logged in to see if anyone replied and oaa new message in this thread...and its my own message :lol:
My new webpage calinmocanu

SamuraiCrow

  • Newbie
  • *
  • Posts: 40
    • Yahoo Instant Messenger - samuraileumas
    • View Profile
Tile Engine
« Reply #5 on: May 01, 2009, 06:51:21 pm »
Batch rendering is the 2d equivalent to mesh rendering in 3d.  It means that since the vertex between 4 tile images is shared between them, it will only calculate the vertex position once and apply it to all 4 tiles.

 

anything