Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Do I need to use CLS?

Do I need to use CLS?

Do I need to use CLS?

I'm writing a maze game where you walk through it and looks like 3-d although its only a crude use of the LINE command really.  However, evertime I move forward in the maze, I use the CLS command and then redraw all the lines to show the new view.  It works but its jerky (i.e. noticeable delay) and looks messy as a result.  I've tried redrawing the lines with the background colour (to blank them out) and then redrawing the new view (therefore not using CLS) but this is still jerky.

Any thoughts on how I might make this better?  Many thanks.
1st post by the way and a newbie programmer to Qbasic.

RE: Do I need to use CLS?

Use page swapping.  Look at the SCREEN statement in QBasic Help's INDEX section.  You want to use the <apage> and <vpage>, which allow you to write your graphics to a hidden page, then switch to the page you wrote graphics to.  You'll find it makes it smoother because you don't see it draw the lines on the screen.

RE: Do I need to use CLS?

you will also want to look at the PCOPY command

If a man says something in the forest and no woman hears it is he still wrong?

RE: Do I need to use CLS?

or you can write to a buffer.  draw your maze to a buffer, then put it on the screen.  that'll eliminate any flicker. but since you are using teh line statement, you'll need to make your own, as you can't use the line statement in a buffer.  you are familiar with y=mx+b, right? you'll also need to know about memory, poke, segments, offsets... on second thought, maybe you should just stick to some simpler things.

wait &h3da, 8

i try to avoid this, as it greatly slows down programs.

this is also faster.

line (0,0)-(319, 199), bf, 0

RE: Do I need to use CLS?

Try something like this, it uses a Screen 9 page swapping routine

SCREEN , , 0, 1   'hides the screen, writing to background
SCREEN , , 1, 0   'switches the screens making the background now visible
x = 1
y = 1
WHILE a% > 1
        a% = INP(96)     'keyboard routine
        IF a% = 77 THEN
                playery% = playery% - 1
        ELSEIF a% = 75 THEN playery% = playery% + 1
        ELSEIF a% = 80 THEN playerx% = playerx% - 1
        ELSEIF a% = 72 THEN playerx% = playerx% + 1
        END IF
        PCOPY 0, 1        'copies the active screen to the background screen
        SCREEN , , 0, 1   'switches so that background in being written to
        SCREEN , , 1, 0    ' switches background and foreground again

If a man says something in the forest and no woman hears it is he still wrong?

RE: Do I need to use CLS?

Many thanks for all the input - I'm experimenting now.

RE: Do I need to use CLS?

You might also want to try simply overwriting the old lines and then drawing the new lines. Like this:


[user/computer movement command entered]


This way only the old lines get "eraced" when you are moving through the maze, removing that terrible "flashing" in between movements. More work? Yes, unless you have a program to generate the LINE values:

LINE (A,B)-(C,D),4,B
LINE (A,B)-(C,D),0,B
LINE (E,F)-(G,H),4,B

Like that. A more simple cure if I do say so!


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close