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 / Clearing a specific area of the screen

Author
Message
Unseen Ghost
22
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 16th Feb 2005 09:54 Edited at: 16th Feb 2005 09:55
Hi,

I was wondering if clearing the screen in a certain area inside the main loop with a statement like below is going to take up a lot of memory adding a black block every time the loop starts again ?

Unseen Ghost
P Schnell
20
Years of Service
User Offline
Joined: 13th Feb 2005
Location:
Posted: 16th Feb 2005 10:58
There isn't a command for it, but:

Depends on why that screen needs to be cleared and what happens before that, you could improvise. I don't know your whole program but here are some things you could do.

Pasting a black image would use less memory (I think) than using the box command.

If you are pasting an image on the screen anyway, why not just include a black part over what you need to be cleared?

You could clear the whole screen and put your text/images in places where they wouldn't interfere with the part of the screen you want black.

If you told what you were using it for we could help you a lot more.

Unseen Ghost
22
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 17th Feb 2005 10:03
I am trying to make a tetris game and I need the screen to stay black behind the image moving down so the image doesn't look smeard.
Here is all my code that I have so far.

Unseen Ghost
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 17th Feb 2005 11:10 Edited at: 17th Feb 2005 11:12
Unseen Ghost,

In this case, if you are not wanting the background to be erased, then make the tetris blocks to be sprites. A sprite, with it's "backsave" property set to 1, will not smudge when moved each loop. So, this gives you two options.

1.)Create all blocks as sprites.
With using a sprite there is no need to clear the screen or
constantly re-paste the background to the screen. Technically,
the sprite redraws the part of the background it covered last, if so be it is no longer covering that area anymore.

2.)Re-paste the background image and then the block image each loop, using the CLS(clear screen) approach.
This method may bring you lower screen rates, due to the whole background image having to be cleared and then re-pasted each loop(in using a sprite, only the part of the background in which the sprite covered has to be redrawn each loop, which is done automatically).

+NanoBrain+
Unseen Ghost
22
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 17th Feb 2005 11:30
I was trying to use sprites while waiting for an answer, but I was having trouble figuring it out. Thanks for the examples. I will let you know how it turns out.

Unseen Ghost
Unseen Ghost
22
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 18th Feb 2005 12:07
Ok,

Here is my latest code below.
Now it says Runtime Error at line 35. Image does not exist.

Loop is highlighted when it gives the error.

All the images are on the screen where I want them. I believe the black image in the middle is pasted also because it does make it past the statement.
What now do I have wrong ?
What image is it talking about ?

Unseen Ghost
Unseen Ghost
22
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 19th Feb 2005 10:46
this is my first time working with the sprite commands. I hope someone can help.

the source code is in the post right above this one.

Unseen Ghost
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 19th Feb 2005 15:40
Unseen Ghost,

In your source, the third image you are trying to load "background" does not have the extension ".bmp" hooked onto the end of it. As a pointer, always take a patient amount of time, in most observentness, to figure out what might be wrong with your program, if so be it is bugged.

+NanoBrain+
Unseen Ghost
22
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 19th Feb 2005 22:29
Usually I do a pretty good job in typing code, but I missed it this time.

Thank you for showing me. I will try it again.

Unseen Ghost
Unseen Ghost
22
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 20th Feb 2005 09:26 Edited at: 21st Feb 2005 04:59
I fixed the mistype, but when I move the block it doesn't redraw the backround. The block looks like it smears and makes a line as wide as the block. Can anyone help ?

Unseen Ghost

Login to post a reply

Server time is: 2025-05-23 21:34:51
Your offset time is: 2025-05-23 21:34:51