Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 adding loading percentages
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
beedub




PostPosted: Thu Jan 08, 2004 8:53 pm   Post subject: adding loading percentages

hey all, i havent done turing in about6 months... and i wanted to make a good loading bar. How could i put the loading percentages at the bottom of this? what would be the code?
heres what i have
code:
for count:100..400
Font.Draw ("Processing",200,230,font2,gray)
delay (17)
drawfillbox (count, 200, count+10, 210, blue)
end for

ty
Sponsor
Sponsor
Sponsor
sponsor
CITC




PostPosted: Thu Jan 08, 2004 9:11 pm   Post subject: (No subject)

that may look nice but it doesnt actually display the correct loading time....

for the answer, hope that someone really smart looks at your thread Confused
santabruzer




PostPosted: Thu Jan 08, 2004 9:23 pm   Post subject: (No subject)

you could always go the cheap way and do:
code:

var font2 := Font.New ("courier:12")
var percent : int
for count: 1..300
Font.Draw ("Processing",200,230,font2,gray)
delay (17)
drawfillbox (count+ 100, 200, count+110, 210, blue)
percent := count div 3
locate (1,1)
put percent
end for
beedub




PostPosted: Thu Jan 08, 2004 9:23 pm   Post subject: (No subject)

its just for display i dont actually need the current loading time
santabruzer




PostPosted: Thu Jan 08, 2004 9:26 pm   Post subject: (No subject)

so you mean something like this or...
code:
setscreen ("offscreenonly")
var font2 := Font.New ("courier:12")
var percent : int
for count: 1..300
Font.Draw ("Processing",200,230,font2,gray)
delay (17)
drawfillbox (100, 200, count+110, 220, blue)
percent := count div 3
locate (1,1)
Font.Draw (intstr (percent),count + 90,210,font2,gray)
View.Update
cls
end for

Tony




PostPosted: Thu Jan 08, 2004 9:28 pm   Post subject: (No subject)

Please tell me you're not one of them dumbasses who put in a "loading bar" with delay in it just for the sake of animation Rolling Eyes If I was a compsci teacher (which I might after I retire) I would fail your assignment right there Laughing Can't imagine how lame and stupid that is...

now in case I got you all wrong - sorry

I wrote up some code for a custom GUI item - percentage bar You might find the code useful. The post also explains and shows how to use it
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Mazer




PostPosted: Thu Jan 08, 2004 9:36 pm   Post subject: (No subject)

Well, loading bars tend to be pretty trivial unless you plan on loading A LOT of LARGE pictures. I'm talking hundreds of pictures, at resolutions of maybe 200x200 or more. But if you are doing a lot of loading and you want to make a good loading bar, try making it more like this:
code:

var picsloaded := 0
loop
    % do loading stuff here
    picsloaded += 1
    Font.Draw ("Loading images...",200,230,font2,gray)
    drawfillbox (100, 200, round (picsloaded / numPics), 210, blue)
    exit when picsloaded = numPics
end loop

That's just an example of how you might want to go about doing it. Keep in mind you'll need a variable or constant for numPics that is equal to the total number of pictures you'll be loading. And if you plan on doing it like that, you'll need to load all of your pictures into a single array or use a whole bunch of ugly if statements. Here's another way to do it:

code:

var picsLoaded := 0
var numPics : int % set this to the numebr of pictures you'll be loading

drawbox (98, 198, 402, 212, 7)
function LoadPic (filename : string) : int
    picsLoaded += 1
    drawfillbox (100, 200, 100 + round (picsLoaded / numPics * 300), 210, blue)
    result Pic.FileNew (filename)
end LoadPic

Instead of using Pic.FileNew to load a picture, call loadpic instead. It's pretty much the same except the LoadPic function will update the progress bar for you, saving you many repetitive lines of code. Also, don't forget to set numPics equal to something (not zero, of course). And you can play around with the code to make the progress bar look different. But yeah, don't just put a loading bar with delays, you should only use a loading bar if the user has to wait for some pictures to load and you don't want them thinking the program crashed.

EDIT: geez, in all the time it took me to type that up, tony posts a link to a progress bar he already made. Confused Arrow Embarassed
beedub




PostPosted: Thu Jan 08, 2004 9:49 pm   Post subject: (No subject)

k ty...
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Jan 08, 2004 9:50 pm   Post subject: (No subject)

haha Laughing sorry about that mazer, I just like to point out that most of the code people look for is already there, they just need to use the Search Laughing
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 9 Posts ]
Jump to:   


Style:  
Search: