Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [LOCKED] Map Data loader

Author
Message
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 7th Nov 2006 12:10 Edited at: 7th Nov 2006 12:20
I have been working recently on a map data loader for my game, which I think would help me make things a little easier. Can I just note, that the data files for Dark Coder's Piper was the inspiration to how this would work, so thanks

This is basically so I don't have to have my level as one big object, and I can add/remove entities from it whenever I want. Once they've been loaded I can do whatever I like with them.

Anyway, rather than just some code, you could call this a compiler/language in a function. You have commands in a text file (any file extention you like) that are read by the function. I only actually have 4 commands right now, but the two of them can be counted as pretty useless, depends really how lazy you are

This is an example of a data file... (you dont NEED the indents, but I find it tidy)


As you can see, I have the commands "NAME", "ADD Sphere", "ADD Cube" and "ADD Object" (it's not case sensitive). You can put the commands in any order you like, so the NAME one could be right at the bottom, or in between any other two commands.
There are braces under the commands, between the braces you put the data, for example, in the ADD Sphere and ADD Cube commands, the data is like this:
-Position X
-Position Y
-Position Z
-Angle X
-Angle Y
-Angle Z
-Size X
-Size Y
-Size Z

It's pretty much exactly the same with the ADD Object, but you have to also put in the directory of your object. The data must be in the right order. The NAME command's data is just the name of the level, which is returned from the function.

Lastly, there are comments in the code, they can be defined by putting, "//", "`" or "rem" before them, and they can't go in any data columns. You don't have to use the //,` or rem to define your remarks, as long as your remark is not a command that's fine, but if it is, then it's best to put one of those just incase

Now, here are the functions, you will need all of them, but you only have to call "startUP" at the top of your code, and then just do "mapName$=loadMap(mapDir$)" whenever you like. (you obviously dont have to get mapName$ . Also comes with a very simple crappy demo.



PS. It wouldn't be a bad idea to use this to load your actual level object too to keep it tidy.

[edit]
I'm also going to add compability with lights.

And also, i'll have to work out a way to return object numbers which are loaded.

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 7th Nov 2006 12:40 Edited at: 7th Nov 2006 13:02
And here's a simple function to get the object of an entity, you just put in the entity number, and it returns the object. You'll have to change the entity number if you change the order of the code.



Also, update the startUp() function to this:



[edit]
And a delete map function.


Time to work on lighting.

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 7th Nov 2006 13:49 Edited at: 7th Nov 2006 15:21
Sorry for third post, but this is too important for an edit I think.

I made point lights work, and also a 'SET World' command, which checks the ambient light, the red,green and blue colors of it, the colors of the backdrop, whether fog is on, it's range and color.

Code:



And a test map.


Just save it as a .txt in your project folder. It feels good to have something like that in only 1 line


[edit]
There, now supports all primitives and is ready to use. I might make a map editor. If anyone can think of anything else (that isn't shaders) then tell me.



And here's a map to try it with.




[edit]
Comments!!

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 8th Nov 2006 21:14
Oh cmon, a home made programming language and no replies?

Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 8th Nov 2006 21:20
This is sweet! Very clever too. Good job Zoto


Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 8th Nov 2006 21:31
YUS! A reply!

Thanks

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 8th Nov 2006 22:43
Uhh, mods can lock this. I just posted a better version in WIP.

Login to post a reply

Server time is: 2024-11-22 23:19:36
Your offset time is: 2024-11-22 23:19:36