Qbasicnews.com

Full Version: Loading Screen
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
Here's my entry. Remove the delay loop if you want to see how fast it can go.

Code:
DECLARE SUB endLoading ()
DECLARE SUB updateLoadingScreen (percent%)
DECLARE SUB beginLoading ()
DEFINT A-Z

SCREEN 13

beginLoading

FOR percent = 0 TO 100

  ' Delay, remove to see maximum speed on your computer:
  st! = TIMER: DO: t! = TIMER: LOOP UNTIL t! < st! OR t! >= st! + .01

  updateLoadingScreen percent

NEXT

endLoading

END

SUB beginLoading

SHARED sectionCol, oldSection, lastPercent

sectionCol = 0
oldSection = 32767
lastPercent = -1

CLS

DRAW "bm141,90c15"
DRAW "nu6r3 br2"
DRAW "buu2ber2bfd2bgnl2br br2"
DRAW "buu2ber3d4nl3 br2"
DRAW "buu2ber3bd4nu6nl3 br2"
PSET STEP(0, -6): DRAW "bd2d4 br2"
DRAW "u4r3fd3 br2"
DRAW "buu2ber3d4nl3d2gl2hbm+4,-2 br2"
PSET STEP(0, 0), 15
PSET STEP(2, 0), 15
PSET STEP(2, 0), 15

CIRCLE (160, 100), 50, 16
CIRCLE (160, 100), 75, 16
PAINT (165, 40), 16
DRAW "bm160,100ta0c0bu35u35"

OUT 968, 14
OUT 969, 63
OUT 969, 63
OUT 969, 63

OUT 968, 32
FOR i = 0 TO 63
  OUT 969, 0
  OUT 969, 0
  OUT 969, i
NEXT i

END SUB

SUB endLoading

FOR j = 0 TO 63 STEP 3
  WAIT &H3DA, 8
  OUT 968, 14
  c = 63 - j
  FOR i = 1 TO 6
    OUT 969, c
  NEXT i
  OUT 968, 32
  FOR i = 0 TO 63
    c = i - j
    IF c < 0 THEN c = 0
    IF i > j THEN c = (c + i) \ 2
    OUT 969, 0
    OUT 969, 0
    OUT 969, c
  NEXT i
NEXT j

CLS
PALETTE

END SUB

SUB updateLoadingScreen (percent)

SHARED sectionCol, oldSection, lastPercent

  section = -((percent * 36) \ 100) * 10
  IF section <> oldSection THEN GOSUB doSection: oldSection = section

  IF percent <> lastPercent THEN
    lastPercent = percent
    GOSUB drawPercent
  END IF

  c = 15 + ((SIN(percent / 4) + 1) * 24)
  IF c <> loadingColor THEN
    loadingColor = c
    OUT 968, 15
    OUT 969, c
    OUT 969, c
    OUT 969, c
  END IF

EXIT SUB

drawPercent:
  p$ = LTRIM$(STR$(percent))
  l = LEN(p$) * 4
  x = 156 - l \ 2: y = 110
  LINE (x, y)-STEP(l + 5, -7), 0, BF
  PSET (x, y), 0
  DRAW "ta0c14"
  FOR i = 1 TO LEN(p$)
    SELECT CASE ASC(MID$(p$, i, 1))
    CASE 48: DRAW "buu4erfd4gl br4"
    CASE 49: DRAW "brru6ngbd6r br2"
    CASE 50: DRAW "bu5erfdg3dr3 br2"
    CASE 51: DRAW "bufreuhnleuhlg bf5"
    CASE 52: DRAW "br2u6g2dr3 bd3br2"
    CASE 53: DRAW "bufreuhlhu2r3 bd6br2"
    CASE 54: DRAW "brbu3rfdglhu4erf bd5br2"
    CASE 55: DRAW "bu6r3dgdgd2 br4"
    CASE 56: DRAW "br2lhuenrhuerfdgfd bdbr2"
    CASE 57: DRAW "brreu4hlgdfr bf3"
    END SELECT
    x = x + 4
  NEXT i
  DRAW "bue3": PSET STEP(-3, 0), 14: PSET STEP(3, 3), 14
RETURN

doSection:

  IF section >= 0 THEN RETURN

  DRAW "bm160,100ta" + STR$(section) + "c0bu40u24bm-2,+10"
  PAINT STEP(0, 0), 32 + 5 + (sectionCol * 58) \ 35, 0

  sectionCol = sectionCol + 1

RETURN

END SUB
Whoa, that's pretty cool! Somewhat small too. Crap, now I may not win Tongue
I've updated the challenges page at QBNZ. Go have a look.
37.5? Cheh, I was expecting at least a 40...

What do you suggest for more color? The reason the program is slow is because it's using a buffer (it can't get ANY faster than just about 40 fps, and even so, you can't notice anything higher than 60)

Do you suggest I take out the buffer and let it have flicker? I hope not.
I get 288FPS uncompiled. Which is really wierd...

The loading bar sucks. There's no indication of where 100% is. The colours are still dark, and the black background can be changed for more points (every entry so far has used a black background, be original!) Also, where is the delay? I did state in the rules that slow screens would be penalised.

However, you get the award for "best variable names" Wink
What do you mean, "Where's the delay?"? I have the percent increased whenever a certain variable equals 10, but no actual delay on the rendering.

Also, there IS a way to tell where the bar ends. Notice how it goes from dark to bright to dark? the last dark is 100. Ok? ahahaha.

The variable names are just stupid crap for FOR loops, or... are you talking about "blorg"?

There's really no way to have a cool background without just making a BSV, but I didn't want external files. Or are you suggesting I have a BRIGHT color scheme with a white background? You should know by now that I'm a dark person.
[Image: me4.png]
Oracle, if I'm not mistaken, this is where you put the loading routines in his program (see the comments):
Code:
WHILE percent < 101
'load all that shi...stuff here and process the percent
'Buuuuut, I'll just fake the percent

REDIM buffer(32001): buffer(0) = 2560: buffer(1) = 200

It's not like it only goes at that one speed, you can increase percent as fast as you like, you just have to take out the lines that fake the percentage.
I don't get it, why no libs?
Blitz: I want to see *your* code. Because 1) I'm not very experienced at using libraries and 2) Some people who enter (probably most) don't know how either, which ruins it for them.

However, you are free to make something with UGL, although it won't count Tongue

Nink: The last dark? I know what you mean, but when it's that dark it's hard to tell. What I want is like a box with the line in it so when the line reaches the end of the box that is 100%.

I'll retest your program for speed later.
Quote:Blitz: I want to see *your* code. Because 1) I'm not very experienced at using libraries and 2) Some people who enter (probably most) don't know how either, which ruins it for them.

I never understood that general opinion/belief. Mostly 'cause using libs makes your life easier. Always. Pure QB stuff, appart from being slow, is harder to code and give you more headaches than LIB stuff. For example, any animation with double buffering in PQB is such a hassle and that can be solved with just three lines of LIB calls.

If you wanna code a double buffered animation in PQB, you may either:

1.- Use SETVIDEOSEG and QB drawing functions.
2.- Code your own blitters that draw to a buffer (PUT compatible, of course)

Both two sollutions are really a big hassle. With most libs, you just create a buffer with a function that returns a handle, then you use that handle and pass it to the drawing functions in the lib, then you use that handle again and pass it to the function that copies the buffer to screen.

If you read this: http://faq.qbasicnews.com/?blast=DoubleB...ngConcepts you'll realize what a hassle is doing stuff in PQB.

Not 'cause it is PQB, just 'cause if you wanna efficient blitters and fast (?) animation, you need to code stuff from scratch, and such things are already cleanly and "fasterly" coded for you in any LIB.

PQB for the challenge of doing it may be cool, but PQB 'cause "LIBs are harder" is a nonsense. In fact, LIBs are there for lazy programmers like me who don't like to reinvent the wheel. If I had to code my blitters and double buffers, I would not code. I'm too lazy Tongue
Pages: 1 2 3 4