Confusion of GML (rgb)

Posted by Siert on Oct. 3, 2006, 4:18 p.m.

Yes I am confused, I can't seem to get down the rgb crap in GML and I don't get it. If you could help me out. I'd post it in the forums but seeing as they're down I have to blog about my troubles.

What I'm aiming for is that when the object gets hit it flashes white the returns to normal.

Heres what I use to set the variables in a create event.

//scrAllInit(sprite_color,normal_health)
color = argument0
local_health = argument1
color_red_def = color_get_red(color)
color_green_def = color_get_green(color)
color_blue_def = color_get_blue(color)
color_red = color_get_red(color)
color_green = color_get_green(color)
color_blue = color_get_blue(color)
hit = 0

Then when the variable hit is 1 it uses this code in the step event

if hit = 1
{
if color_blue < 254
{
color_red -= 1
color_green -= 1
color_blue -= 1
}
else
{
color_red += 1
color_green += 1
color_blue += 1
}
if color_blue = color_blue_def
{
hit = 0
color_red = color_red_def
color_green = color_green_def
color_blue = color_blue_def
}
color = make_color_rgb(color_red,color_green,color_blue)
}

Yeah, I've never done this before (suprisingly). I need some help on this. I need to leave soon because I'm not supossed to be here. If you help I'll put you in the credits. I don't think thats a big reward but thats all I can do. This is finally the game I'm going to complete after four ideas and not actually starting on any of them. I think that school stole all of my time for a while there.

Comments

Alert Games 18 years, 1 month ago

Should work. The only thing I saw was the fact that there could be negative numbers…

Wait, change the < 254 to > 254. Read that part out loud and see why.

Polystyrene Man 18 years, 1 month ago

Check out this minigame I made. I think it does what you're trying to do (and unregistered, as well).

noshenim 18 years, 1 month ago

you cam make a duplicate sprite by greyscaling sprite with gm, and draw that instead of the normal sprite in a additive blend mode.

draw event:

if(omg_hit){
draw_set_blend_mode(bm_add)
draw_sprite(spr_player_grey,image_index,x,y)
draw_set_blend_mode(bm_normal)}
else draw_sprite(spr_player,image_index,x,y)