Flashing white effect

Previous topic - Next topic

Falstaff

I want to have an effect where a sprite flashes white, but I'm not sure how to achieve it. I am drawing my sprites using POLYVECTOR commands, and noticed that there is a way to specify a colour when setting pixels, however white is used as the 'normal' colour.

So I know how to make something draw that is say, blue, but not white!

Any ideas?

erico

Is it a single frame flash?
What do you mean by ´normal´color?
Can´t you use a blue-almost-white? like RGB(254,254,255)?


Is your avatar a mix between crazy little boy+little prince?

Wampus

Ah. I think that you want to draw a normal 'sprite' using a pure white texture but using the alpha channel for transparency? I'm fairly sure its not possible to do that in GLBasic without importing some C commands to call OpenGL functions like glTexEnv directly. Even then it could get messy, e.g. you might end up with faint white boxes around the edges of your sprite or similar issues. Worth a try though.

fuzzy70

I remember seeing a post on the forum once talking about changing the texture coords in polyvectors to display a different part of the bit map, could you not double the size of your bitmap by adding a pure white block next to the main sprite like this, bad ascii art incoming  :D

+-------------+-------------+
|                  |                 |
| normal      |  white       |
| sprite        |  sprite      |
|                  |                 |
+-------------+-------------+

I'm assuming that's the effect you are after if not sorry  :noggin:

Lee
"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

matchy

To create a "camera flash" effect on an 2d or 3d drawn object, rapidly raise the ALPHAMODE to +0.9 (flood white) then back to 0.0 in animation.

Falstaff

#5
Erico: I had tried that but it has little effect, I think the closer you are to 255,255,255, the closer the pixel is to it's original colour.

Wampus: Yeah I think that's what I want. and yeah I'm not sure about this route you mention..!

Fuzzy70: Hm I suppose that's one approach, but frankly we're already trimming animation frames because we don't want to run out of resources loading all of our sprites, so I don't think I want to double our memory footprint for 1 simple effect.

Matchy: Ah - hah! This could be it :) I'll have a go at that, I like the sounds of this solution best.

Thanks everyone for all the suggestions!

AlienMenace

Just add an all-white version of of your sprite on the sprite sheet somewhere then set a flag in your collision routine to draw the sprite from the new location in your polyvector draw routine. I did this in Quixotic by setting a collision flag then unset the flag after drawing the white sprite so it would draw properly the next loop.


Apps published: 3

Slydog

#7
Is this a single-coloured sprite? (other than black)
If so, create just a white sprite, then draw it with (255,255,255) for the 'flash' effect.
Then, normal drawing just colour it using different values: (255,0,0) for red for example.
This only works for sprites that are one shade of course.
And may have performance issues for some mobile devices (which prefer pure white shading).

Does using (0,0,0) cause the sprite to draw all black? (exact opposite of what you want!)

I like the APLHAMODE idea, using 'additive' values (positive).
I wonder is simply drawing the same sprite over itself using a '1.0' ALPHAMODE would result in white?
Or, just drawing it once may work as Matchy suggests. (using '0.9')

My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

matchy

I think ALPHAMODE +1.0 will produce pure white where as the lesser is the sprite with white opacity (or is it 0.9999?  :whistle:).  :good:

Just to side note, unlike variable polyvector where the vertex color can be changed in loop when drawn, a 3d model is initially created with a fixed color. It's not feasible to recreate a 3d object (by changing the vertex colors only) in a loop.

If you want to change the color of an object, it definitely faster and better to use alternative sprites and textures as alphamode is just the easiest way (and may not work on all devices).

Wampus

Quote from: Falstaff on 2012-Feb-28
Wampus: Yeah I think that's what I want. and yeah I'm not sure about this route you mention..!

Creating a plain white sprite just for the flash frame might be easier. However, I know the above should be possible since I saw it often offered as the solution when I googled it. If I wasn't so busy right now I'd try to test out how to get it working in GLBasic because its quite a useful thing to know. It would go something like this...

IMPORT "C" void __stdcall glTexEnvi(unsigned int flag, unsigned int flag, unsigned int flag);
GLOBAL GL_TEXTURE_ENV = 0x'Approprite Hex Value'
GLOBAL GL_TEXTURE_ENV_MODE = 0x'Approprite Hex Value'
GLOBAL GL_MODULATE = 0x'Approprite Hex Value'
GLOBAL GL_ADD = 0x'Approprite Hex Value'


Then, after STARTPOLY has been called and before the first POLYVECTOR that needs to drawn as all white you can set the blend colour to white then change the texture environment parameters with...

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);

then back to...

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

when you want to return to the default GLBasic mode.

I'm not sure what the hex values would be (could be queried using glGetTexEnv) and there is more to it than the above, but it should be possible.