Play World United
Would you like to react to this message? Create an account in a few clicks or log in to continue.


The best place to be if your looking to make, play, or just talk about games.
 
HomePortalLatest imagesSearchRegisterLog in

 

 Enemy Color Health Example

Go down 
AuthorMessage
hardcoregamer
Newb
Newb



Posts : 6
Join date : 2008-06-07

Enemy Color Health Example Empty
PostSubject: Enemy Color Health Example   Enemy Color Health Example I_icon_minitimeSat Jun 07, 2008 5:45 pm

Many people have been asking for enemy health examples. Enemy health is basically variable manipulation. Many times people have not asked for something that expands enemy health, which is enemy coloring. Enemy coloring can be a sign of how close the enemy is near to death. Enemy coloring depends on enemy health. Today we are going to present an easy example on how to make some good enemy health!

First we must create our enemy. all we need in our creation code is:

Creation code:

enhealth=10 /// sets the health
color=c_lime; /// sets the original color

Now here is our step code, the most important code:

//sets the color based on health
if
enhealth>8
{
if
enhealth <10
{
/// sets the health
color=c_lime; /// sets the original color
}}

if
enhealth>6
{
if
enhealth <7.9
{
/// sets the health
color=c_green; /// sets the original color
}}

if
enhealth>4
{
if
enhealth <5.99
{
/// sets the health
color=c_orange; /// sets the original color
}}

if
enhealth>2
{
if
enhealth <3.499
{
/// sets the health
color=c_red; /// sets the original color
}}

if
enhealth>0
{
if
enhealth <1.99
{
/// sets the health
color=c_maroon; /// sets the original color
}}

if
enhealth<.1
{

//if no more health the enemy dies
effect_create_above(ef_explosion,x,y,1,c_red);
instance_destroy();
}

The next to the last code is the collision code with a bullet!

enhealth-=1; ///subtracts health
with other instance_destroy(); ///destroys the bullets

The last code is the Draw Event:

draw_sprite_ext(sprite_index,image_index,x,y,image_xscale,image_yscale,image_angle,color,image_alpha);

//the color is the variable that is the color seen in the step event.

Now thats all you need. This code works with gm7 registered and lite if you tweak it right. The example can be downloaded from one of the link below:
Back to top Go down
 
Enemy Color Health Example
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Play World United :: Game Maker :: Examples-
Jump to: