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.

2D All the way! / Sprite Clipping?

Author
Message
Chromehawk
20
Years of Service
User Offline
Joined: 29th Jun 2003
Location:
Posted: 9th Sep 2003 04:35
I'm working on a project where sprites move around in a smaller window within the larger area of the screen. Is there a way to have the sprites "clip" so that only part of them are visible as the go on an off the displayable area?

Thanks for any info.

ChromeHawk
heartbone
21
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 9th Sep 2003 11:37
Yes.

Use other sprites to make the edges of the playfield and make the clipped sprite a lower display priority than the edge sprite(s).

The more you see, the more you know.
The more you know, the more you see.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 9th Sep 2003 11:59
There are two other possibilities-

1. Paste your sprite images to a smaller bitmap then copy that bitmap to the main display

2. Convert to using planes (plains?) and change the viewport size
Chromehawk
20
Years of Service
User Offline
Joined: 29th Jun 2003
Location:
Posted: 11th Sep 2003 05:21
heartbone wrote:
>Use other sprites to make the edges of the playfield and make the >clipped sprite a lower display priority than the edge sprite(s).

Hadn't thought of that, thanks. To make the lower display priority do I make the sprite number smaller or bigger?

In other words, is "sprite 1, x, y, img_num" higher priority than "sprite 246, x, y, img_num"?

Thanks for the tip!

ChromeHawk
Chromehawk
20
Years of Service
User Offline
Joined: 29th Jun 2003
Location:
Posted: 11th Sep 2003 05:24
IanM -

You said paste the sprite images to a bitmap and then past that to the main display area. Is that essentially setting a "mini" double buffer sort of affair?

ChromeHawk
heartbone
21
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 11th Sep 2003 07:30 Edited at: 11th Sep 2003 07:36
The sprite priority is determined by instantiation order, not the sprite number.
If I create Sprite 2 first and then Sprite 1,
Sprite 1 will sit on top of Sprite 2.
If I were to create Sprite 1 first,
then Sprite 2 has priority.

(It is possible that I have this behaviour reversed, this is from memory, but...) The last created sprites superimpose the earlier ones.

Beware, displaying very large sprites can drastically decrease the performance of DBC. Keep them as small as possible.

The more you see, the more you know.
The more you know, the more you see.
Dreamora
21
Years of Service
User Offline
Joined: 20th Sep 2002
Location: Switzerland
Posted: 11th Sep 2003 18:07 Edited at: 11th Sep 2003 18:11
I think
SET SPRITE PRIORITY Sprite Number, Priority

would help too, if you are using DBP (he didn't write which one)

For DBC you will have to maintain a "plain"listing which knows at any moment which sprite is in which "plain" and then draw the sprites in the order from back to front. for this i would suggest a 2 dimension array and giving the "most back" position the highest "z-Value". with this you can use insertion sort to maintain the array and displaying sprite is just display spritenumber from arrayindex 1 to NumberOfSprites
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 12th Sep 2003 00:02
@Chromehawk, it's a sort of double-buffer.

The main idea is that the sprites are clipped to this smaller bitmap, then you use the COPY BITMAP to update your screen bitmap.

I can't guarantee how fast (or slow) it will be though - you'll just have to try it.

Login to post a reply

Server time is: 2024-05-05 14:55:25
Your offset time is: 2024-05-05 14:55:25