How to make a sprite flash white on 1 image only

BlitzMax Forums/BlitzMax Programming/How to make a sprite flash white on 1 image only

Matt McFarland(Posted 2006) [#1]
Hey All,
I tried setting the colors to like 500,500,500 but that didn't work. I tried light blending it too but still didn't work. I was wondering if there is any way to do this without having to make another image file? OR do I have to make a new image file? I'd really prefer the former. Your thoughts?

-Matt


Haramanai(Posted 2006) [#2]
The only way I can think it's to change the color value of the spite to white 255 , 255 , 255 using the ReadPixel for pixmap. There is an example that inverts the colors in the wiki : ReadPixel


TartanTangerine (was Indiepath)(Posted 2006) [#3]
You want to flash sprite pixels? You could overlay the sprite on itself with LIGHTBLEND, that would do the job. You might need a few layers though.

Or use specular lighting.


tonyg(Posted 2006) [#4]
It might depend on the effect you're after.
This makes it look like the image is flashing...
Graphics 800,600
image:TImage=LoadImage("max.png")
While Not KeyHit(key_escape)
  Cls
  DrawImage image,0,0
  If KeyHit(key_space) 
     SetBlend lightblend
     DrawImage image,0,0
     SetBlend maskblend
  EndIf
  Flip
Wend



Matt McFarland(Posted 2006) [#5]
Ok, so I just draw another lightblend image of itself on top of it if it is going to flash. I'll try this out! Seems simple and effective! Thanks! :)


ImaginaryHuman(Posted 2006) [#6]
In OpenGL, if you have set your alpha channel to be either 1.0 for Pixel and 0.0 for No Pixel, to do masking, then you could set your drawing mode to GL_ALPHA which would take only the alpha channel and create corresponding grayscale R G and B channels from the same data, so where you have 1 in the alpha you would have 1 in R G and B, making white. Of course if your alpha has some gradual levels then those too would be transferred into grayscale.


Matt McFarland(Posted 2006) [#7]
AG: I'm using DirectX on everything else.. I can't combine DirectX and open_GL right? But I suppose I could switch to OPEN_GL easily right? At any rate, what is faster and more compatible?


TartanTangerine (was Indiepath)(Posted 2006) [#8]
Stick with DirectX for compat. But OpenGl does appear to be faster.


Matt McFarland(Posted 2006) [#9]
Thanks! I'll be sticking with DX and apply the lightblend overlay :) I appreciate everyones help on the matter.

-Matt


ImaginaryHuman(Posted 2006) [#10]
If you do DX it will not work on linux or mac whatsoever, just to bear in mind.

Your other option is just keep a copy of the `white` thing in memory as a second image.


Matt McFarland(Posted 2006) [#11]
hmm.. If I make a linux/mac version all I need is to set it in OPEN_GL mode right? I'm not using any explicate DX commands just BMAX stuff..


xlsior(Posted 2006) [#12]
hmm.. If I make a linux/mac version all I need is to set it in OPEN_GL mode right? I'm not using any explicate DX commands just BMAX stuff..


As long as you only use the standard built-in Max commands, it will work on either Windows, Linux -or- a Mac.

when you compile under windows without specifying the graphics type it will default to DirectX (and apparently fall back to OpenGL if DirectX is not available). the same code will automatically compile for OpenGL on Mac & Linux.


ImaginaryHuman(Posted 2006) [#13]
How they used to do the sprite flash in the old days was take the separate mask (or alpha channel) and draw it with an AND operation to remove whatever pixels were existing beneath it, then draw it with an OR operation.


SSS(Posted 2006) [#14]
why not use multiply blend with a white rect over the image?


Matt McFarland(Posted 2006) [#15]
SSS: Wouldn't that make it look ilke a rect then?


SSS(Posted 2006) [#16]
if you use multiply blend then black behind the object would stay black... i dunno, it seems to me like it would work. Although, if there's a background you'd have to deal with it some how...