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 Professional Discussion / Loading bar/percent complete

Author
Message
Dark Basic Pro Enthusiast
12
Years of Service
User Offline
Joined: 8th Nov 2013
Location:
Posted: 6th Mar 2014 17:10 Edited at: 6th Mar 2014 17:12
okay so for my game I have a main menu, but since it takes awhile on my school computer to load, I want to be able to have something that shows how far along the loading process is. This is the part of code that I want to add in the percent complete.

I tried to just put "print '50%'" along the part that loads, but it doesn't seem to work. any ideas?
P.S I realize this is a long code, me and my group partner are trying to clean it up a bit. Also, my partner uses my account, so sorry about the multiple posts

tiffer
20
Years of Service
User Offline
Joined: 6th Apr 2006
Location: Scotland
Posted: 6th Mar 2014 17:25 Edited at: 6th Mar 2014 17:31
If you space out blocks of code and put little notes in every so often it will make it a hell of a lot easier for others to read through your code to help you.

The problem your idea didn't work because the the point of turning sync on means that the screen will not refresh until the next sync command. Try this. Paste the below function into the bottom of your source (after the game loop). Then in the part of ur code u want to display ur message just do for example screenprint("50% complete")




edit: You can always tweak it to suit. For examply if you want a different background color just change the ink rgb value to something else.

Cwatson
ShellfishGames
13
Years of Service
User Offline
Joined: 6th Feb 2013
Location:
Posted: 6th Mar 2014 17:47
@tiffer, is there a reason why you put sync off and sync on around the cls/print code? I don't quite see what difference it makes in the context. Also, instead of ink rgb(0,0,0),0 : box 0,0,1024,768, you could just write cls rgb(0,0,0) - or did you use box on purpose? I don't think there's a difference (unless you're drawing to a render target supporting transparency, but that's clearly not the case here). I mean, your code would certainly work as expected, I'm just curious why you implemented it this way.
Other than that I agree - the missing syncs probably cause the text not to be rendered when expected.

Also, @DBP Enthusiast, taking into account your second thread - this:



Would be perfect for a for loop:



(Ignoring this strange exception of number 2 being loaded with ID 200, as ID 2 is already occupied by another image... )

tiffer
20
Years of Service
User Offline
Joined: 6th Apr 2006
Location: Scotland
Posted: 6th Mar 2014 18:52 Edited at: 6th Mar 2014 19:36
@shellfish games : You couldn't be more wrong. You want to be able to display the message in one iteration (step) and remain there while the program is loading. If you don't turn sync off you will get a black screen due to the double sync buffer. If you double sync you will get a blue (the 3d backdrop) screen. The only possible way is to sync off. print the message sync the screen and then turn sync back on again for the program to load the rest of the game.

Beleive me I didn't write it this way for fun.

Cwatson
ShellfishGames
13
Years of Service
User Offline
Joined: 6th Feb 2013
Location:
Posted: 6th Mar 2014 22:15 Edited at: 6th Mar 2014 22:16
Given that "I couldn't be more wrong" I'm wondering why the version without sync on : ... : sync off and with cls instead of box seems to work just as well.



Run the code and select "New Game"... the first few messages are printed to the screen using your function, the last few with a simple cls - center text - sync approach.

Quote: "If you don't turn sync off you will get a black screen due to the double sync buffer."


This is only the case if you keep constantly calling sync on in the middle of the program.

Quote: "If you double sync you will get a blue (the 3d backdrop) screen."


As the backdrop isn't turned on in DBP Enthusiast's code, that's hardly an issue.


Not meaning to be rude or anything, but answering my question why you wrote your function that way with "you couldn't be more wrong" (I didn't even state anything to begin with) isn't the nicest imaginable move.

tiffer
20
Years of Service
User Offline
Joined: 6th Apr 2006
Location: Scotland
Posted: 7th Mar 2014 16:42
Sorry if I'm offending you but I only posted the function to help the op and I'm not sure why you would criticize my logic on it instead of simply asking 'why?'

The above function was based on one of my older projects. During the process of procedurally building the models and map the loading screen function wasn't working until I inserted sync off at the beginning and sync on at the end. Sync by it's self didn't work. I had to turn sync off for it to work and that meant I had to sync back on again at the end. So now you know why I wrote it this way for the OP, do you have any more questions?

Cwatson
Dark Basic Pro Enthusiast
12
Years of Service
User Offline
Joined: 8th Nov 2013
Location:
Posted: 7th Mar 2014 17:15 Edited at: 9th Mar 2014 01:10
Quote: "Thanks guys! I hadn't even thought of using a function to do this type of thing. thanks again"

okay so I implemented all of the stuff you said to and this is now my game (with the exception of the function at the bottom
but it still doesnt work... any ideas? or am i just doing what you told me wrong? i am new to this,sorry.

ShellfishGames
13
Years of Service
User Offline
Joined: 6th Feb 2013
Location:
Posted: 7th Mar 2014 17:35
Quote: "Sorry if I'm offending you but I only posted the function to help the op and I'm not sure why you would criticize my logic on it instead of simply asking 'why?'"


OK then, I wasn't intending to critisize your logic, I was just curious. Sorry about the misunderstanding.

@DBP Enthusiast - simply put this line inside your code:



Just as tiffer said. Since the function-definition is in your code as well, DBP will recognize screenprint as an executable function (although it will probably not be highlighted in the editor, but it will still work).

By writing your own functions you can basically enhance DBPs command set by adding your own functionalities. The only difference is that unlike usual commands, you have to use parantheses when calling your self written functions. So 'screenprint "50% complete"' would not work, but 'screenprint("50% complete")' does.

tiffer
20
Years of Service
User Offline
Joined: 6th Apr 2006
Location: Scotland
Posted: 7th Mar 2014 17:42 Edited at: 7th Mar 2014 17:48
Don't ignore the brackets.

paste in bottom (out of loop)


paste at start


paste half way


Edit No problem shellfish.

Cwatson
Dark Basic Pro Enthusiast
12
Years of Service
User Offline
Joined: 8th Nov 2013
Location:
Posted: 10th Mar 2014 16:09
Okay, so I think I am just going to stop trying to do this. I have followed every direction you have said, but nothing works. this is my code by the way:

I think it has something to do with my main menu, but i am not sure. Although, thank you both for the help
ShellfishGames
13
Years of Service
User Offline
Joined: 6th Feb 2013
Location:
Posted: 10th Mar 2014 16:28
Your main loop is missing a Sync. Hence nothing after the "Loading..." is ever drawn (because you set sync on in the beginning (line 9) you have to call the sync command manually - if sync on wasn't set, DBP would do that automatically at the end of each do/loop, repeat/until or while/endwhile cycle). Also, in the code you've just posted, the function definition of screenprint() is missing.
I altered the code by adding the sync to your main menu loop and the function declaration to the very bottom, and it works just as expected:



Dark Basic Pro Enthusiast
12
Years of Service
User Offline
Joined: 8th Nov 2013
Location:
Posted: 11th Mar 2014 16:21
Quote: "Also, in the code you've just posted, the function definition of screenprint() is missing."

This isn't my entire code, it is just a snippet of the actual thing, and the function was at the bottom of the entire code. Thank you very much for all the help, it is working great now!

Login to post a reply

Server time is: 2026-07-06 07:15:51
Your offset time is: 2026-07-06 07:15:51