• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Making the enemy flash when hit

N

NoConnection_

Guest
Hi.

So recently I thought of a bright idea to make the enemy flash when hit by bullets. I tried to come up with a way to do it and the only idea I thought of is to make my sprites white and then do set_sprite when hit. Is there another easier way?
 

Kyon

Member
So there is this cool thing called image_blend.

Create event:
Code:
blend=image_blend
blendtime=0;
- first we make some variables.

Collision with bullet:
Code:
blend=c_white; blendtime=room_speed;
- when you collide with a bullet, the blending of your image becomes white, so, like a flash, and the blendtime will be how long it'll be white.

Step:
Code:
if blendtime>0{
blendtime-=1;}else{blend=image_blend;}
- This code is when your sprite is blended white (because it has just been hit by a bullet) it'll put it back to it's normal colours after 1 second.

in your draw event:
Code:
draw_sprite_ext(sprite_index,image_index,x,y,image_xscale,image_yscale,image_angle,blend,image_alpha);
- to make this all work use this line of code, I'm changing the "image_blend" for the variable "blend" that we created in the create event.
 
N

nicoltoons

Guest
if place_meeting (x,y,obj_bullet)
{
image_blend = make_color_hsv(// check the value of the color you want in a graphic software)
alarm[0] = 45
}

in the alarm [0] event
image_blend = make_color_hsv (//value for white color) // white or the color of the player.

Use a software like photoshop to get the color you want

//explanation of code .. if bullet hits the player, change the color of the player sprite to whatever color you want and let the player be that color for 45 steps then go back to its original color which is a white color.
 
N

nicoltoons

Guest
Better still @NoConnection_ Don't be afraid of using in built effects in game maker studio or your own.

This is another way
if place_meeting(x,y,obj_bullet)
{
effect_create_above(ef_spark,x,y,20,c_white)
}
OR
get a blood spill animation, create a sprite and an object with it then do this

if place_meeting (x,y,obj_bullet)
{
instance_create(obj_bloodspill, x,y)
}

//Animation End of obj_bloodspill

instance_destroy()
 
N

NoConnection_

Guest
Search the forum for flash. This has been answered many times before.
Looking up image_blend in the manual may be helpful for you.
So there is this cool thing called image_blend.

Create event:
Code:
blend=image_blend
blendtime=0;
- first we make some variables.

Collision with bullet:
Code:
blend=c_white; blendtime=room_speed;
- when you collide with a bullet, the blending of your image becomes white, so, like a flash, and the blendtime will be how long it'll be white.

Step:
Code:
if blendtime>0{
blendtime-=1;}else{blend=image_blend;}
- This code is when your sprite is blended white (because it has just been hit by a bullet) it'll put it back to it's normal colours after 1 second.

in your draw event:
Code:
draw_sprite_ext(sprite_index,image_index,x,y,image_xscale,image_yscale,image_angle,blend,image_alpha);
- to make this all work use this line of code, I'm changing the "image_blend" for the variable "blend" that we created in the create event.
I highly recommend this tutorial video. I use this method when my player or enemies take damage.

if place_meeting (x,y,obj_bullet)
{
image_blend = make_color_hsv(// check the value of the color you want in a graphic software)
alarm[0] = 45
}

in the alarm [0] event
image_blend = make_color_hsv (//value for white color) // white or the color of the player.

Use a software like photoshop to get the color you want

//explanation of code .. if bullet hits the player, change the color of the player sprite to whatever color you want and let the player be that color for 45 steps then go back to its original color which is a white color.
Better still @NoConnection_ Don't be afraid of using in built effects in game maker studio or your own.

This is another way
if place_meeting(x,y,obj_bullet)
{
effect_create_above(ef_spark,x,y,20,c_white)
}
OR
get a blood spill animation, create a sprite and an object with it then do this

if place_meeting (x,y,obj_bullet)
{
instance_create(obj_bloodspill, x,y)
}

//Animation End of obj_bloodspill

instance_destroy()
Thank you everyone that took the time to try and help me!
 
Top