How do i make a level with tiles?

Started by
13 comments, last by Servant of the Lord 11 years, 6 months ago
Hi, I am using C++ and SFML2.0 and c++ Visual 2010. I want to make a level out of tiles but do not know how to. So far this is what I have done. I got 1 tile type and i am putting it together in photoshop to make a map. I then separate each string of tiles and put them manually into the code. So for one map i will be making over 30 Sprites and turn them into blocks and draw them out, then i will have to make boundaries for them separately. This takes a very long time and i am sure that there is a much faster way for example using xml but i don't know how to put that into the code. If you need the code just ask and i will post. Also just to clarify i dont want to make a tile engine which automatically makes them like minecraft. I want to make a puzzle map like bloody trapland so I will have to place them myself. Please help, urgent.
Advertisement
Have a look at http://www.gamedev.net/topic/622801-sfml-tile-maps/. If you want specific answers like code, then you will have to post your program.
I'd recommend reading this thread also, where I've explained the basic idea: [size=2](At the risk of turning this forum into someplace that just responds with links)
http://www.gamedev.net/topic/629742-2d-overhead-tiling-engine/page__p__4970743#entry4970743

If neither of these links help you, if you ask specifically what part you are having difficulty with, we're happy to help.
i have already seen http://www.gamedev.n...sfml-tile-maps/ and don't want this. i recently made a map using "tiled map creator" but it is only one layer will i need more than one? if so why(just so i know when to do it)? I am completely new also i am using SFML 2.0 not 1.6. The 2nd post helped a bit. Also just some background info. I am 16 and started learning c++ in july and have finished a book and online tutorials, i will still have to go over it to understand it better. I am learning at home as i am in school still doing A-Levels if you know what that is. I am completely new to SFML but i am picking it up quite quickly. This is just a little project that im doing so i can build a strong and solid base before i go to uni in 2 years time. plan to go into game development. sorry got a bit sidetracked.

so once again i have built a map using "Tiled map creator" i am just using one tile but has one layer , i dont know if i need more, if so tell me. i want to know how i can load that map which is in a weird format into my game using sfml 2.0.
Whether you need more layers or not depends on how you are designing your own game.
Maybe this will help you load the maps. Scroll down to the fourth post or so, and there's a SFML 2.0 compatible version.
i tried that before but did not understand how to install tinyxml and didnt understand it much. i am talking about the level.cpp and .h i will take a look again and try to understand it but on the weekend i dont have that much free time.
Well, sometimes you run into walls. That's the time when you need to figure out how to get around or over the wall, instead of turning around and leaving thinking it a dead end.
If you couldn't figure out how to install tinyxml, that's the time to keep on trying to figure it out until you succeed, breaking each problem into tiny pieces and researching online how to get over that specific problem, step by step, until you succeed. If a specific problem gives you trouble, and after you've researched it and still can't find a solution, then post on a forums asking for help with that specific step (and mentioning what you've already tried).

I've never used tinyxml personally, but most libraries you don't "install", you download and then link to.

There will always be walls in your way; the skill you need to learn is how to get over them.
Yes that was what i was thinking last night, as that will be a valuable skill and a great skill for a game developer/programmer.
Hi,

Have you looked at Tiled Map editor? Its a free tile-based map editor with open-source. It has integration via xml and .Json I believe.

http://www.mapeditor.org/

Not sure if it will help for your game though.
Have you thought about a class or struct consisting of character arrays containing numeric letters to determine which tile to be used in conjuction with a function call to a scene renderer?

What I would do is create a class for the tiles, create a class for the scene renderer, and pass the appropriate tile/tiles as many times as you would like by simply sending an argument of which tile, how many tiles, their positions, to the scene renderer which then draws them on to the screen when necessary, and deletes the garbage(memory)needed when the tiles are offscreen or not shown, etc.

I'd say that SDL(SimpleDirect Media Layer)is a pretty easy library for blitting images to a window.

In SDL you can accomplish an image to the screen as easy as:


typedef SDL_Surface * LOAD;
LOAD Screen = SDL_SetVideoMode(800, 600, 32, SDL_FULLSCREEN);
LOAD PlayerImage = "IMAGE.jpg";
SDL_BlitSurface(PlayerImage, NULL, NULL, Screen);
SDL_Flip(Screen);
SDL_Delay(3000);


You can also add some more data to maybe flag certain tile types as "solid" so the playable character or enemy will not walk over or "through" it.
Yes, this is red text.

This topic is closed to new replies.

Advertisement