• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Josip Mati?

Level file creation

6 posts in this topic

Hello

 

Following my code refactoring spree for Battle City, I'd like to improve loading and storing of levels. After some limited searching (I'm on vacation with limited access to the Internet) I couldn't find anything that I could use.

 

Currently, my levels look like this:

[Level1]
S0W0000S0000W0S
000000ttt000000
0MGM000h000MGM0
0GGG00ygl00GGG0
0MGM00BBB00MGM0
000000BWB000000
GGGGGGGWGGGGGGG
WWWWWWGGGWWWWWW
GGGGGGGWGGGGGGG
000000BWB000000
0MGM00BBB00MGM0
0GGG00s0a00GGG0
0MGM0000000MGM0
000000fhd000000
00W001kCj200W00

Which is simple: read with double For loop char by char and create tile which that char represents.

 

There are few problems with it that I notice :

  • Amount of characters I can use for that is limited. Tiles like brick wall require not 1 but about 13 - one character for each variation of the tile.
  • Approach is ok for 15x15 tiles, but it may cause problems if I ever expand to a variable dimensions (with 15x15 being minimum). Not only the text file will become huge or at least wide, reading each level will become painfully slow with current system.

So, my questions are:

  1. Since I use XNA, is XML good enough for storing level data? I'd like to store tiles as either list of "type subtype position" or "type position_rectangle source_rectangle". I've been searching Internet a little and found a way to do a variation of that but for single level only, is there a simple way to do that for all levels in one file?
  2. This is probably too broad question and too low-level for C# - if I decide on writing a custom level data type, what are the general ideas behind it? I couldn't find anything or the Net (or my searching skills suck) and with my knowledge I only though of creating the binary file and write in it what I need or want.

Maybe I'm just thinking too hard.

 

Thanks in advance, even if the answer is just "search better" :)

0

Share this post


Link to post
Share on other sites

You can look into using JSON rather than XML as parsing them in C# is a breeze although to be honest it's probably easier (and faster, if file read/write really is a bottleneck) to serialize and deserialize your level data to some custom binary type. How are you going to be constructing your level files? With some custom tool or hand written? I.e. how important is "human readable" to your format needs?

1

Share this post


Link to post
Share on other sites

Given that it's just a tilemap, can't you just resort to an array of bytes? (you'd get 256 possible tile types, should be more than enough for you) True, you'd need to add a small header at the beginning indicating the size, but that should be trivial.

 

Of course you'd need to make a level editor to go along with it, so that'd be probably the hardest part. But you were planning to do that anyway, right? (I don't think you'll want to edit a tilemap from an XML or JSON file!)

2

Share this post


Link to post
Share on other sites

Given that it's just a tilemap, can't you just resort to an array of bytes? (you'd get 256 possible tile types, should be more than enough for you) True, you'd need to add a small header at the beginning indicating the size, but that should be trivial.

 

*facedesk*

 

Array of bytes did NOT occur to me. So I just write header + array into binary file, right?

 

Level editor is actually complete and working, I'll just need to modify it for a new type. However, code for loading and saving is a mess since I currently use simple text file - one huge Switch which creates new object of type Tile (custom written class).

2

Share this post


Link to post
Share on other sites

Can't you use some tile editor (such as this: http://www.mapeditor.org ) and adapt your code to load from its format?

 

I could, thanks for informing me of it.

 

However, for the first major project I'd like to make everything myself in order to grasp the basics behind it ;) So, page is bookmarked for later projects.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0