Hello,

I've started work on building a 2d tile based platform game, and have just been wondering about how to store/distribute the games levels.

this game allows you to load a 'World' which is made up of potentially up to 10000 map files (A 100x100 grid, though most of
the time this grid won't be filled). The map files are just more grids of tiles.Anyways, I't seems like having up to 10000 small files in a folder seems like a inefficient way to do this.

I tried to find any useful help but unable to find anything extremely helpful.

I figure that the best thing to do would be to compile all the maps into one world file, and just load that file into memory.

I have thought about just creating one xml file to store everything, but I'm not too sure about it.

Your Answers will be helpful

Thanks
Jay

Hi

I was considering the same question myself. I looked at a couple of good tutorials at vbprogramming8k, which taught me how to store data in a notepad text file. If you use a loop and a 2D array to store all the data, you can access numbers from the text file and convert them to images. What language are you coding this in?

Please tell me if anyone knows another way.

Just store your data in one file for each map, simple solution. Each row is a row in the map, and each value between commas in a column:

1,5,6,3,5
4,8,9,6,4
2,4,6,7,6
0,0,1,3,2
5,7,4,2,1

That could be a 5 x 5 map. Then just read the file and split data into a 2D array or a list, depending on your programming language.

Hi

I was coding a strategy game with ships the other day, and I was wondering how to draw the ships in. I figured maybe a notepad file like shadwickman said :). However, if I want to give a ship an individual identity, how does it work? Cause if each ship is identified by say a 1, and there are 4 of these, how do I specify an action to occur to an individual ship?

Thanks

Ohhh boy. It looks like you need to actually learn a programming language still. What are you currently making this game in? It sounds like you don't know the basics of what an object is, or about classes and inheritance, etc... Are you using VisualBasic or something?

Hi

I am coding in Visual Basic.NET, and yes, I do understand how classes and the other stuff works. At the moment I have got a notepad file and my program takes the numbers from there to convert to data. Maybe I didn't express my problem clearly. The only problem at the moment is how to access the individual data for each ship. I have a piece of an array for each ship, so in that sense I know what the name of each ship is. But the name isn't the whole identity of each of the objects, is it?

I never have used VB, but what you'd need is to track the pointers to the ships in an array (or objects in the array, however VB does it). That way you can directly access the ship instances through the array. In Python it would be like this:

# my ship class
class Ship(object):
    def __init__(self, name):
         self.name = name

# test ships
a = Ship("Galleon")
b = Ship("Skiff")
c = Ship("Rowboat")
myships = [a, b, c]  # list of ship objects

# access ships
print myships[0].name  # result is "Galleon"
myships[1].name = "Wreckage"
print myships[1].name  # result is "Wreckage"

You can see that the list contains the objects so that you can directly modify them or access their properties.

Hi

Thanks, Shadwickman. I'll try out your solution ASAP.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.