GameMaker LT pamoka 23#RPG Gyvybės,priešas ir kita.





Player-craete:

global.hp=50 // Startiniai sveikatos taškai
global.max_hp=50 //Daugiausia sveikatos.
alarm[0]=90; // Tarp regeneracijos sveikatos taškų intervalas.

Alarm {0} :
global.hp+=3;
alarm[0]=90;

Step:
....
   global.max_hp+=10 //Padidina givybes.
    global.hp=global.max_hp //Jei Hp daugiau už max_hp ,vistiek buna lygu su max_hp.
    }
    

if global.hp<1 then room_restart();
if global.hp>global.max_hp then global.hp=global.max_hp; // Tai apsauga ,kad nebutu 150/100.

Priešas-create :
hp1=30;
smugis=true;

Priešas-Alert {0}:

smugis=true

Priešas-Step :
image_angle = direction

if (distance_to_object(Player)< 150)
{
speed=2;
 direction=point_direction(x,y,Player.x,Player.y)
}


if (distance_to_object(Player)> 150)
{
speed=0;
}

Priešas-Step2 :

if hp1<1
{
global.xp+=20-(global.level+1)
instance_destroy();
}

Priešas-Player:
if smugis=true
{
global.hp-=5
smugis=false
alarm[0]=30;
}

Priešas-Left pressed:

 if object_exists(Player)
{if distance_to_object(Player)<50
{
hp1-=5;
}}


Priešas-draw :
draw_sprite(sprite_index,image_index,x,y);
draw_set_color(c_white);
draw_set_font(f_HP)
draw_text(x-18,y-25,"Hp:" + string(hp1));

Hud-draw :
draw_text(view_xview+5,view_yview[0]+40,"Givybes:" + string(global.hp) + "/" +string(global.max_hp));//Parodo givybes.

Komentarų nėra:

Rašyti komentarą