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

Author Topic: What data structures should I use for a Roguelike random dungeon tilemap?  (Read 2975 times)

0 Members and 1 Guest are viewing this topic.

mosatramparen

  • Newbie
  • *
  • Posts: 2
    • View Profile
In a school project we are creating a roguelike game and it's my job to create the dungeons. To my understanding the best way to do this is to use VertexArrays because of performance reasons. However, since the dungeon will be randomly generated, it's not possible to have a complete texture for the dungeon. We will be creating our own textures as well.

One idea that came to my mind would be to generate the dungeon and then create the dungeon texture by looping over the quads and adding the corresponding individual texture (wall, door, corridor etc). This way I would only have to loop through all the tiles once and then I could draw the tilemap with a single draw command. Does this sound like a reasonable way to go about? I'm a bit concerned that this will be non-trivial, because our time is limited.

This comes to my second question: if we say that the map will have a maximum size of 300x300 tiles, can I get away by just drawing every quad individually? This way I could just create a Tile class with a rectangle member and texture it depending on its type. I know that this would be suboptimal, but given our time constraint I would rather take the easier option this time around.

jamesL

  • Full Member
  • ***
  • Posts: 124
    • View Profile
Re: What data structures should I use for a Roguelike random dungeon tilemap?
« Reply #1 on: November 16, 2016, 09:01:25 am »
you probably won't get an answer

they're pretty strict about keeoping this an SFML forum and not a generic C++ or generic game dev forum

you could try some of these
https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=game%20dev%20forums

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10918
    • View Profile
    • development blog
    • Email
Re: What data structures should I use for a Roguelike random dungeon tilemap?
« Reply #2 on: November 16, 2016, 10:25:57 am »
Why would you think it's not possible to use one texture if it's procedurally generated? How will you procedurally generate the texture then?
I'd assume you'd use a render texture to render the different procedural elements onto. Then you could simply get the texture from the RT and use that.

300 x 300 tiles = 90000 tiles = 180000 triangles
Whether this can be rendered easily or not highly depends on the hardware, but generally this should be doable for most systems. However if possible, I'd probably still try to use a vertex array if at all possible.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

sjaustirni

  • Jr. Member
  • **
  • Posts: 95
    • View Profile
Re: What data structures should I use for a Roguelike random dungeon tilemap?
« Reply #3 on: November 16, 2016, 02:18:07 pm »
Not strictly related to the question, but here is a must-read article if you want to procedurally generate dungeons, if you haven't read it already: http://www.gamasutra.com/blogs/AAdonaac/20150903/252889/Procedural_Dungeon_Generation_Algorithm.php

mosatramparen

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: What data structures should I use for a Roguelike random dungeon tilemap?
« Reply #4 on: November 16, 2016, 03:31:01 pm »
Why would you think it's not possible to use one texture if it's procedurally generated? How will you procedurally generate the texture then?
I'd assume you'd use a render texture to render the different procedural elements onto. Then you could simply get the texture from the RT and use that.

300 x 300 tiles = 90000 tiles = 180000 triangles
Whether this can be rendered easily or not highly depends on the hardware, but generally this should be doable for most systems. However if possible, I'd probably still try to use a vertex array if at all possible.

Sorry for explaining it poorly, turns out that I don't understand texturing completely. So my intuition tells me to create a "Tile" data structure that contains a Rectangle shape, and associate a texture with it (e.g. a wall texture or floor texture). Can you explain to me why  it would be more efficient to use a vertex array, and maybe a possible way to implement it? Not in complete code of course, but in general steps.