Changing sprites -just- before they're blitted to the screen?

Started by Scavenger, Thu 20/08/2009 03:33:10

Previous topic - Next topic

Scavenger

I've been trying to work out for ages how to alter sprites just before they're blitted to the screen. This will be incredibly useful for the transparency plugin I'm using for my game - it would mean I can have transparent objects and characters rather than simply using overlays.

Unfortunately, I've been reading the plugin API extremely intently, and I've seen no reference to catching sprites before they're blitted, only when they're loaded. This means that if the plugin tries to implement the transparency, it will only be against the background, and instead mask out the objects behind the translucent character. It's important that the screen is already half drawn before the sprite is changed, as this will give the plugin an accurate description of the screen behind the character.

I reiterate, I don't want the sprites before any of them have been blitted, nor when all of them have, but when some of them (the ones drawn behind the translucent actor) have been blitted.

If anyone has a workaround for this, it would be awesome.  And if not, is there any hope that the hook to catch sprites before they are blitted can be added to the plugin API (similiar to the "Sprite is loaded into the cache", but called at a different time, I guess)? I believe it could be quite useful for those wanting a half-completed screen to mess around with. Apologies if this has already been asked. :)

monkey0506

For transparency why can't you just use Character.Transparency and Object.Transparency? I don't understand why you need a plugin for this...?

Scavenger

Because I'm not using 16bit graphics, I'm using 8bit. I need to have control over the background image and the sprite as it's being blitted so that I can achieve the desired effect.

It's a stylistic thing. 16bit transparency looks completely different.

Edit: I'm also using a plugin because AGS doesn't allow direct memory access to dynamic sprites in script, and Get/PutPixel is really really slow.

Pumaman

You can't modify sprites just before they're blitted to the screen, for two reasons:

(a) AGS stores the sprite in memory. If you modified the image then that change would be permanent and would also affect the sprite the next time it was drawn
(b) In AGS's rendering loop, it no longer has knowledge of sprite numbers, therefore even if there was a hook to intercept each bitmap being drawn, you wouldn't know which sprite number it corresponded to.

A workaround might be to create an alternate copy of the sprite and then change the object/character sprite number in the AGSE_PRERENDER event to use the new copy.

SMF spam blocked by CleanTalk