4 Replies - 3738 Views - Last Post: 18 January 2011 - 03:26 PM Rate Topic: -----

#1 Kurupted  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 15-January 11

Tile-based map c++, sdl help please.

Posted 18 January 2011 - 01:45 PM

Hello all,

This is my first post. I am fairly new to c++ and newer to sdl. I wish to make a tile-based game, simply as a learning project and was hoping to get some help with displaying a random and dynamic tile map. I have finished StayCrisp's tutorials for the game engine, and was hoping someone could help me implement the map into that engine.

Right now I use a simple array to hold the value of 100 map tiles which I pass to an update function. However, this is very sloppy, not oop, and from what I have read from very random posts I should not be using an array for the tiles, though the people that said not to didn't specify why.

I am decent with classes, pointers and most of the basics, but vectors elude me. I need some practice with them as simply reading gets me nowhere. I could ramble on for a while, but my main point in this post is help with the map and possibly implementing it into stayscrisp's game engine.

I want the map to be random (though I think I can randomize the tiles on my own), I want to be able to store the tiles that aren't being displayed somewhere but without a limitation to the map size (as I would like the map to grow as far as the player explores), and most of all I would love some help.

Sorry for the long post. Thanks to all in advance.

Is This A Good Question/Topic? 0
  • +

Replies To: Tile-based map c++, sdl help please.

#2 Aphex19  Icon User is offline

  • Born again Pastafarian.
  • member icon

Reputation: 615
  • View blog
  • Posts: 1,873
  • Joined: 02-August 09

Re: Tile-based map c++, sdl help please.

Posted 18 January 2011 - 02:00 PM

Quote

I am decent with classes, pointers and most of the basics, but vectors elude me. I need some practice with them as simply reading gets me nowhere.


A vector is simply a line segment which has direction and magnitude, don't overthink them so to speak, a vector itself is infact very simple.

Quote

without a limitation to the map size (as I would like the map to grow as far as the player explores)


Maybe an std::vector would be best if you want a dynamically expanding array.

This post has been edited by Aphex19: 18 January 2011 - 02:00 PM

Was This Post Helpful? 0
  • +
  • -

#3 Kurupted  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 15-January 11

Re: Tile-based map c++, sdl help please.

Posted 18 January 2011 - 02:06 PM

Quote

without a limitation to the map size (as I would like the map to grow as far as the player explores)


Maybe an std::vector would be best if you want a dynamically expanding array.
[/quote]

Thank you for the speedy reply. I will look into that. Is what I am speaking of fairly straightforward? Do I simply save 'grids' of my map to seperate files to be called when needed?
Was This Post Helpful? 0
  • +
  • -

#4 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 945
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: Tile-based map c++, sdl help please.

Posted 18 January 2011 - 02:35 PM

Moving this to Game Programming, you may get better answers there.
Was This Post Helpful? 0
  • +
  • -

#5 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 1
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Tile-based map c++, sdl help please.

Posted 18 January 2011 - 03:26 PM

There are several problems with your proposal:

1. As the player explores the size of the map will grow. you will need to set some kind of limit on this.
2. You can't practically store the tiles that you want to store 'somewhere' in memory.

So you will need to devise a way of partitioning the space that the tiles occupy and maybe store a simplified representation of those tiles that are unlikely to be referenced regularly off to file. Does that sound like quite a task?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1