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

Author Topic: What would be most efficient?  (Read 1399 times)

0 Members and 1 Guest are viewing this topic.

The Terminator

  • Full Member
  • ***
  • Posts: 224
  • Windows and Mac C++ Developer
    • View Profile
What would be most efficient?
« on: October 19, 2012, 07:52:00 pm »
I'm creating some tilemap support for my engine, and I can't really decide which two ways to go about it. Here's two ways I thought of: (P.S. I plan to load the tilemap from an external file such as a .txt)

1:
Each tilemap would be represented as a child class that would be derived from a base class called TileMap. To draw this tilemap when the character does something such as reaches the edge of the map, you would pass a reference to the object of the child class and it would draw that specific class. A camera would not be needed as the certain tilemap would be seen as a whole on the screen.

2:
Have 1 huge tilemap that periodically draws itself when the character moves in a certain direction. Once the character has reached the edge, it will collide and stop. A camera will be needed because the tilemap would need to scroll in the direction that the character is moving. There would only be one class called TileMap with methods such as void drawMap(), etc.

It would be helpful for some advice to pursue this task. Thanks in advance!
Current Projects:
Technoport

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: What would be most efficient?
« Reply #1 on: October 21, 2012, 06:34:44 pm »
I wouldn't do one or the other... ;)
Instead I'd use a sf::VertexArray which will represent the whole tilemap, I then only render what is actually displayed on the screen and make use of sf::View for scrolling.

But I can't give you any more hints on that topic since I haven't implemented a tilemap on my own. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: What would be most efficient?
« Reply #2 on: October 21, 2012, 07:46:13 pm »
There's an example on the wiki that works for square, static tiles.
Back to C++ gamedev with SFML in May 2023