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 / The Vanishing Box Trick

Author
Message
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 1st May 2012 17:09
Why do my boxes keep vanishing? This used to work in DB Classic.



WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 1st May 2012 19:42
I believe it's a graphics card issue, some don't like drawing lines and pixels either... I'm not sure but Advanced2D might be able to solve that...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 1st May 2012 19:52
Will try advanced 2D thanks!

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 1st May 2012 20:30
It still doesn't work. It's like I have a cls, but I don't.

29 games
20
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 1st May 2012 23:16
I believe it because of the different ways in which DBC and DBPro handle sprites.

I'm not sure I'm going to get the technical language of this correct but DBC handles sprites as it handles other 2d commands such as LINE, BOX and PRINT.

In both DBC and DBPro, for any 2D only program you have to use CLS to clear the screen otherwise you end up just drawing over what's already there.

However, again in both DBC and DBPro if you have any kind of 3D in your game, ie. just using the MAKE CUBE command for instance, the SYNC command will act to clear all the screen including anything drawn in 2D.

In DBP, as far as I understand, sprites are essentially 3D plains so 3D is "invoked" and the SYNC command acts to clear all the 2D stuff off the screen. Which is what is happening in your program as you are using a sprite.

I don't know if I've explained that properly so here are a couple of examples.

The first program just draws a 2D box and uses the PRINT command to show an incrementing number. Notice how in both DBC and DBPro, the number being printed is not cleared it just prints on top of the previous number. When the number goes above fifty the white box is no longer being actively drawn but remains on the screen.



The second program create a sprite at the begining. Notice that in DBC is works exactly as described above (but now you see a small square at the top middle of the screen). But in DBP, the value being printed to the screen is legible, as if what was there before has been cleared from the screen. And once the number goes past 50 the white box disapears because it is no longer being actively drawn to the screen.



You'll also notice how in DBC the background is black for both programs, which to me means it's running in 2D. In DBP the first program runs with a black background (indicating 2D only) but the second program has a blue background, indicating it's running in 3D. Because you were colouring your background black, it masked this clue making the problem a lot less obvious to spot.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 2nd May 2012 00:36
So I need to get rid of the sprite.

Andrew_Neale
16
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: The Normandy SR-2
Posted: 2nd May 2012 00:42
You could simply turn the 'auto-clear' off using the 'backdrop off' command.


Previously TEH_CODERER.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 2nd May 2012 00:59
I've tried backdrop off. I think that the sprite turned it back on again.

29 games
20
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 2nd May 2012 02:02
Try something like this:



It's a mod of my previous code, this time the 2D box (now multiple boxes) are draw onto an off screen bitmap (bitmap 1) and then this bitmap is copied to the screen (bitmap 0) so you can see the picture as it's being created. The sprite is now a green square that is positioned at the mouse coordinates so you can move it around. Once the incrementing number goes past 50 then boxes are no long actively drawn but because bitmap 1 never gets cleared they remain on the screen. My guess is that the reason the screen is now black instead of blue is because bitmap 1 has a black background and, as it's the same size as the screen, completely obscures the default blue 3d background).

Sorry for the lack of comments in the code but I really aught to go to bed now.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 2nd May 2012 03:12
Thanks! I have got rid of the sprite, and now it works.

Login to post a reply

Server time is: 2026-07-08 07:05:45
Your offset time is: 2026-07-08 07:05:45