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.

DarkBASIC Discussion / Level Loading (Just a few questions)

Author
Message
Yodaman Jer
User Banned
Posted: 20th Feb 2009 23:43
Hey all, I've just been wondering about this lately. I will state that I have no idea how to load level files or create one or anything like that. I am curious as to how the process works, but that's not what I'm really asking about.

How does one implement a loading bar into their game? How do you make the game know just what percentage of the game is loaded? I've tried Googling this to get answers, but the only things I could find were things about designing levels and such, which really wasn't what I was looking for.

I realize that this is a pretty noobish question, but I still am very interested in how the process works. Can anyone fill me on the details?

Stefan p
16
Years of Service
User Offline
Joined: 2nd Nov 2008
Location: Online
Posted: 21st Feb 2009 00:07
Well to make a loading bar i would just make you loading bar in paint or whatever then spilit it 20 times or more then just keep adding to the bar thoughout the loading code

All fears must be overcome before feeling true happieness.
By Stefan aka me
Yodaman Jer
User Banned
Posted: 21st Feb 2009 02:58
I know that's the basic concept, but I'm not quite sure how one would make that work. Is there any example code on how to make a loading bar anywhere? As I said in my last post I tried Googling but didn't really find anything.

BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 21st Feb 2009 06:59
You could load the file in a loop and as it loads it updates the bar every 1% where 1% is the total size/100.

Here is some pseudo code:



Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Yodaman Jer
User Banned
Posted: 21st Feb 2009 18:15
OK! Thanks BN2, that helps me a lot.

Satchmo
19
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 22nd Feb 2009 03:07 Edited at: 22nd Feb 2009 03:14
Here is a loading format I am using for a game I am making.

Read all the comments! I added some to help you understand it a little better.


A little explanation of commands.

open to read 1,"Example.txt"
Use this command to oped files to read, make sure they are in your project folder. The 1 before the filename says what channel your working with, and don't try to open two files on the same channel without closing the file first, using the

close file 1

command. Again, 1 is the channel you use to tell what file to close. I recommend always closing files after your done with them.

read string 1,T$ : OBJECT_X_POSITION = val(T$)

The read string command will read a line of text from a file(specified channel using 1) and put it into a variable, T$. It is read as text, not values (even though you would write numbers into a file, they are saved as text), so we must convert it into a value using val(T$) and then save it into the OBJECT_X_POSITION variable to use later in the loop. When a line is read, the next time you use the read string command it will automatically read the next line, no need to specify the line to read.

BTW: We need to find out how many objects there are so we know how many to read.

As for Example.txt, you can use any file type you want, as long as that is the file type you saved it as. For example you could call your level Mylevel.lvl.

Depending on how complex you want your levels, you might need to add more data to each object:
I.E. A size variable

read string 1,T$ : OBJECT_X_POSITION = val(T$)
read string 1,T$ : OBJECT_Z_POSITION = val(T$)
read string 1,T$ : OBJECT_SIZE = val(T$)
read string 1,T$ : OBJECT_TYPE = val(T$)
read string 1,T$ : OBJECT_ROTATION = val(T$)

When writing your levels, the level file for the loading code I gave would look something like this

56
100
2
250

And they would represent

Where to position the object on the x axis
Where to position the object on the z axis
The type of object( I.E a cube or sphere)
The rotation of the object

At the beginning of the file there would be the number of objects in the level(This is important).

A real level file might look something like this



So that about covers loading, if you need anything cleared up don't be afraid to ask.

Oh and TDK's file access tut helped me quite a bit when I was learning.

Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 22nd Feb 2009 05:54
a loading bar:

just use a sprite it only needs to be a box that is a sliver wide then in the loop just use stretch sprite command and it will get bigger lol
Yodaman Jer
User Banned
Posted: 22nd Feb 2009 21:02
@ Satchmo: Thank you for writing that up!! It's very detailed and will help me in the future, for sure!!

@ Caleb1994: Yeah, I was thinking about something like that, or what Stefan P suggested and just make a few little images that appear as the level loads.

BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 22nd Feb 2009 21:23
Quote: "read string"

I thought I recalled hearing that the READ STRING will only be able to return a string with (I think) 255 characters. Not sure though, but I seem to remember it coming up in a challenge at one point.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 23rd Feb 2009 00:30
i don't know about that but for what he is doing his lines are only 3 4 or 5 characters in length

Login to post a reply

Server time is: 2025-05-18 19:01:22
Your offset time is: 2025-05-18 19:01:22