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 / Loading bar

Author
Message
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 30th Oct 2007 19:13
Greetings!

This is an example of how to make a loading-bar to show how far your game is loaded:



Here is how it works:
1) type the function "loading(step#)" spread out in your program. Best, you
use it 50 times.

2) The step# value is 250 divided by the number of functions "loading()" in
the program : in this case, 5

3) NEVER put the command "sync" and dont turn the backdrop on before the
start of the game.

I hope you have fun!

Oooooops!!! I accidentally formated drive c.
TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 31st Oct 2007 03:42
Do you know what the # symbol means in a DB program?

TDK_Man

Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 31st Oct 2007 23:04
Nothing is being loaded

"You must be someone's friend to make comments about them." - MySpace lied.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 7th Nov 2007 17:32
No, I dont know what the # symbol means in a DB program, TDK_man. You mind explaining?

Of course there is nothing being loaded... Its an example you can put in front of every game you create, to show how far everything has been loaded.

Oooooops!!! I accidentally formated drive c.
Veron
19
Years of Service
User Offline
Joined: 22nd Nov 2006
Location:
Posted: 13th Nov 2007 13:04
The "#" symbol means that the number is being worked out as a floating point number, or, a number with a decimal point on the end. You don't need the "#" because you're not using a decimal point on the end for loading, it's a whole number, or an integer.

Float: 2.333, 5.22, 3.1
Integer: 1, 2, 3


TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 14th Nov 2007 01:42
Yup - Veron is correct.

A lot of newcomers think that the hash symbol (#) makes a variable numeric in the same way that the $ sign makes one a string, but this isn't true.

The reason it makes a difference (because your programs still work using floats), is that floats need more memory and are really slow in calculations when compared to integers.

This isn't that important with small programs, but in larger ones the difference soon mounts up and with DB Classic, we need all the speed we can squeeze out of it!

Besides, think of all those # symbols you won't have to type...

TDK_Man

Insert Name Here
19
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 14th Nov 2007 18:03
Someones americanised my keyboard so whenever I press " it comes out as @ and # comes out as $ So no hashing is good.


Sudoku arts, the rabi and Nancy DrewG
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 15th Nov 2007 06:20
I feel like writing something so I'm going to analyse a line of your code that can be changed to be more efficient, I'm doing this to help you learn not to make fun of your code.

This is the line I've chosen:
inc green : if green>255 then green=255
What the computer will do here is increase green by 1 (you can specify a different increment if you want), then check if green is over 255 and if it is, green will be assigned the value 255.
Here's the process the computer will go through:

Notice how after the 2nd iteration green is being increased for no purpose, this will continue for the rest of the program.

A more efficient way of doing this would be to have the computer check the variable before altering it:
if green<255 then inc green
So now green will only be increased if it is below 255.
Here's the process the computer will go through:

The computer is doing half the work this time.

Like I said earlier, it is possible to specify an increment with the INC command. My example comes into problems here:

When we increment by 3 green gets stuck on 256 which is too large for a single colour value. The resolution is to check the value of green after we have altered it; doesn't that sound familiar? It's your original line! Not quite (get ready for a tongue twister); because we are only altering after a check, we will only perform our second check if the first check was true.
Maybe I should let my code do the talking

So now we can keep the maximum of green to 255 and still save the computer a lot of work.

ADVANCED SOLUTION
I am currently in a phase of trying to condense my code by using maths instead of IF statements etc.
Here is my solution to this line:

Woah! That was more complicated than I first thought, I spent a good 30 minutes working on that one line
I will now attempt to explain what all that does.

The first part
((green<(255-s))*s)
will return 3 (or whatever the step value is) if a full step can be added to green, if not it will return 0.

The second part
+ (green>=(255-s))
acts a bit like ELSE in an IF statement. It will return 1 if a full step cannot be made or 0 if it can. This is added to the first part because one must always be true (anything is either true or false).

The third part
- (green>(255-1))
stops anything being added once green has reached 255. It is subtracted from the second part to cancel out its effect.

Well there you go, I think I learnt something new, hope you did too

"You must be someone's friend to make comments about them." - MySpace lied.
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 15th Nov 2007 06:31
woah! I got a bit carried away there, sorry dude
That's what I love about programming, there are a million ways to write a single line

"You must be someone's friend to make comments about them." - MySpace lied.
Insert Name Here
19
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 15th Nov 2007 17:56
Quote: "I feel like writing something so I'm going to analyse a line of your code that can be changed to be more efficient"


Classic.


Sudoku arts, the rabi and Nancy DrewG
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 21st Nov 2007 16:47
Thats cool man. Ill put that in my code straight away! Thanks!!

Oooooops!!! I accidentally formated drive c.

Login to post a reply

Server time is: 2026-07-06 11:06:22
Your offset time is: 2026-07-06 11:06:22