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

Author Topic: Easy way to create game levels?  (Read 8854 times)

0 Members and 1 Guest are viewing this topic.

ekeimaja

  • Guest
Easy way to create game levels?
« on: November 20, 2012, 09:13:04 am »
I would like to get this kind feature for creating levels for 2D games in SFML. Level file would be as text file.

Text file:

  F            
============

Initializing and loading of text file:
TileMap gamelevel = TileMap.FromLevelAsset("level1.txt");

Loading and setting of letters/marks in text file.
gamelevel.SetTileMethod('=', CreateGround);
gamelevel.SetTileMethod('f', CreateFlag);

And then own fuctions CreateWall() where setting of colors, sprites and so on.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Easy way to create game levels?
« Reply #1 on: November 20, 2012, 10:16:51 am »
If this should be a feature request (although it's in the General Help section), then I can tell you that SFML won't support anything like this. SFML is made to provide 'lower' level functions for handling media files. So the feature you want is very specific and would maybe be useful to some of the users, but it would also be a very useless feature for others.

If this is a help request (since it's posted in the general help section), then I don't see the question. Remember we're not here to code stuff for you. If you want XYZ then you have to go and implement it on your own and if you get stuck at some point you can ask for help.
What you need is a simple parser that reads your tilemap file and then you need a class that handles the tile map itself (which underneath should be best implemented as a VertexArray).
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

ekeimaja

  • Guest
Re: Easy way to create game levels?
« Reply #2 on: November 20, 2012, 10:35:03 am »
And there is one hidden question: What is easiest way to create levels in SFML? :)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
AW: Re: Easy way to create game levels?
« Reply #3 on: November 20, 2012, 10:49:27 am »
And there is one hidden question: What is easiest way to create levels in SFML? :)
Well what do you need to know more? Because you give quite a nice way of doing things.

The questions for easiest/best/fastest are wrong questions to ask, because everything is relative to different variables.
For some way X might be easy, where as for others X is extremly complicated but Y isn't.
Or for game Z it's a very good idea, to handle things like thos, but for another game K it just doesn't work.

If the way you do things work fine then go this way. As I already said your design seems fine to me. ;)
« Last Edit: November 20, 2012, 10:53:35 am by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

ekeimaja

  • Guest
Re: Easy way to create game levels?
« Reply #4 on: November 20, 2012, 11:07:34 am »
I have used one XNA "distro" library before SFML, where leves were made as i told in first message. I have found some topics about level creating with XML, but nothing about how to do it. Tile programs are not so familiar to me.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
AW: Easy way to create game levels?
« Reply #5 on: November 20, 2012, 11:20:32 am »
Yes?
If you want help in any direction you need to explicitly ask a question.
Like I already said, you need to open and parse the file. This is some basic C++, with which you should familiar with; if not go read about file and string streams. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

ekeimaja

  • Guest
Re: Easy way to create game levels?
« Reply #6 on: November 20, 2012, 11:51:52 am »
Question was in title actually. I am now remaking with SFML one of my game, which is done with C# and that early mentioned "distro" There levels have been created with those text files. But making levels with tile program would be also nice to try something new and different.

Midleiro F

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Easy way to create game levels?
« Reply #7 on: November 20, 2012, 09:18:18 pm »
I have been using Tiled (http://www.mapeditor.org/) for creating game levels. You load tilesets into the program and it associates each tile with the index that is the position of the tile sprite on the tileset. It's quite easy to create and to define custom properties for each tile. It outputs all the map properties to a xml file, which you can then read from your program.

StormWingDelta

  • Sr. Member
  • ****
  • Posts: 365
    • View Profile
Re: Easy way to create game levels?
« Reply #8 on: November 23, 2012, 08:40:20 pm »
The way to make levels and what way is easiest is completely dependent on what kind of game you're making.


Most RPGs and similar games use a tile mapping engine of some kind or a map editor to make the maps.
Space games like the ones I normally work on tend to have a world system of some kind that holds all objects for the world/level.

Not sure of other ways but these are just two and are common enough to have some useful info on them.
I have many ideas but need the help of others to find way to make use of them.

gyscos

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Re: Easy way to create game levels?
« Reply #9 on: November 23, 2012, 09:25:13 pm »
I can only second Midleiro's post on Tiled, the mapeditor. Really and convenient easy to use, it can output to many file formats - and you can even define your own. I use the json format, since I already included a json library but no xml one, but there are many other available.

 

anything