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.

Newcomers DBPro Corner / When using the command 'sprite' all previous pasted image disappear

Author
Message
SJPro
21
Years of Service
User Offline
Joined: 3rd Jul 2003
Location:
Posted: 21st Sep 2009 23:50
I have a tiled background generated using the paste image command. When I then use sprite command the tile background disappears and leaves just a blue screen and my sprite. Why is this and how do I avoid it?

Thanks in advance.
Colonel_Klink
17
Years of Service
User Offline
Joined: 20th Dec 2006
Location: Within the dark recesses of my mind
Posted: 22nd Sep 2009 02:00
Sounds to me like you need to redraw the background before you update any of the sprites. I've not delved into the sprite side of things in DBPro but my 2d programming on the Atari required redrawing the back screen and sprites to a buffer then redrawing on the main screen.

Oh my gosh! He's wearing Full Metal Pyjamas!
--------------------------------------------
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 22nd Sep 2009 07:09
Colonel_Klink is right. You have to redraw the tile map every time you use a sprite. Sprites are treated like 3D plains so the blue screen will always be seen if you don't update the background too.

Here's an example:


Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 22nd Sep 2009 13:42
If you want the sprites to stay where they are, then you need to increment them, like use a global variable to track the current sprite number, and sprite them on, just like with a PASTE IMAGE.

Remember though that there is also the PASTE SPRITE command. But...

Really you'd be better off with another technique for handling your tiled backdrop. For instance, a matrix where each tile is set from a tile sheet, you'd just need to make the right size matrix, set the matrix tiles to suit your map, then it'll be a 3D backdrop, and sprites will sit on top of it, paste image etc would sit on top as well but underneath the sprites. One benefit in this is that you can avoid resizing issues - like if you use PASTE IMAGE or even PASTE SPRITE, you are most likely restricted to 1 single screen resolution. With the matrix backdrop you can zoom in and out and rotate and everything - all just by changing the camera position and rotation.

One other consideration would be to make 1 big sprite, and draw the tiles onto a bitmap, grab the bitmap, then that's your sprites texture. You can actually make a backdrop that is bigger than the screen, then by specifying the sprites UV coordinates, scroll the screen. Might be a bit fiddly - but just consider what faster methods are available to replace PASTE IMAGE. Personally I would avoid redrawing the tiles each loop, and I'd avoid having all those sprites on screen at once, so I'd probably go for a matrix - perhaps switching to a memblock matrix eventually for a bit of a speed boost.


Health, Ammo, and bacon and eggs!

Login to post a reply

Server time is: 2024-11-25 01:57:42
Your offset time is: 2024-11-25 01:57:42