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

Author Topic: Help with tile map adventure game.  (Read 1337 times)

0 Members and 1 Guest are viewing this topic.

rockerdanmatt

  • Newbie
  • *
  • Posts: 1
    • View Profile
Help with tile map adventure game.
« on: August 12, 2012, 03:43:14 pm »
Hey I've recently started using SFML to construct a new 2D adventure game, nothing fancy but somewhere to start.

However I need to understand how I am going to represent each map segment. My screen size is 600 by 400 and each 10 by 10 pixels should be an image, whether it be the player or a wall or just some dirt on the floor. This means I will need 2400 objects per map segment (60 x 40).

The world will be split up into around 10 map segments for now, however this is most likely irrelevant.

My issue is that I'm not sure how to make the most of SFML by using the right objects for the job, I have a single Image file which represents the 10 by 10 entities in the game and I'll be using Sprite.SetSubRect to select which ones. I'm wondering how to represent each of my 2400 objects per map segment. What would the best course of action be, 2400 sprite objects in an array?

Thanks for reading and thanks for any replies!  ;D

massive_potato

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Help with tile map adventure game.
« Reply #1 on: August 12, 2012, 09:37:42 pm »
Since you know the dimensions of each map screen (60 x 40), an array of 60 elements by 40 elements would suffice.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10916
    • View Profile
    • development blog
    • Email
Re: Help with tile map adventure game.
« Reply #2 on: August 12, 2012, 10:01:17 pm »
I suggest you to use SFML 2.0 and its sf::VertexArray for the tile map (you can find several examples in the forum, make use of the search function to find them).
If you're wondering about code design in general I'd suggest you take a look at the MVC pattern, but keep in mind if you're just starting off this can be quite a challanging task. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/