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

Author Topic: beginner problem MapRenderer  (Read 1086 times)

0 Members and 1 Guest are viewing this topic.

Daiky

  • Newbie
  • *
  • Posts: 2
    • View Profile
beginner problem MapRenderer
« on: June 06, 2013, 10:49:42 am »
Hello,
I'm just starting with SFML (I have 4 years experience with SDL and 20 years with C++) with plans to create a simple tile based 2D game.

So I took the C++ version of MapRenderer: https://github.com/SFML/SFML/wiki/Source%3A-TileMap-Render to have  a starting point.

I have a tileset of 64x64 tiles called tileset.png. So I figured if I replaced the following things:
default tileSize  --> tileSize=64,
texture.create(1,1); --> texture.loadFromFile("tileset.png");
src = IntRect(0,0,1,1); --> src = IntRect(0,0,64,64);
In the provider function I've put in comment the part where the color is set.

I would see my first tile to be drawn over the creen, but I just get a blank/black screen. I must be missing something obvious, but I'm probably looking over it everytime...
The texture loads fine...


Daiky

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: beginner problem MapRenderer
« Reply #1 on: June 07, 2013, 09:12:36 pm »
I changed this line of code (line 194 of the C++ tutorial):

rt.draw(&vertices[0], vertices.size(), sf::PrimitiveType::Quads);

into this:

rt.draw(&vertices[0], vertices.size(), sf::PrimitiveType::Quads, states);

and now it works.... If this is wrong in the tutorial, it probably should be fixed, or it might keep beginners like me searching for a while on the reason why their tilemap texture is not showing.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: beginner problem MapRenderer
« Reply #2 on: June 07, 2013, 09:43:45 pm »
It's not a tutorial. The wiki is maintained by users, feel free to correct the code if you found a bug ;)
Laurent Gomila - SFML developer

 

anything