B
BanCannon
Guest
I want to have a sort of heart container system where there is an initial sprite that is worth more than 1 health, but any that are added to it are only worth one. Thanks to a couple different tutorials I have a working system in place, but I want it to look better and take up less room.
Here is my code in the Stats object:
As of right now this means that instead of making a zigzag pattern like I want, it makes all of the sprites change y position together. I'm pretty new to all of this, so any help is appreciated.
Here is my code in the Stats object:
Code:
Create Event:
/// @description Initialize Stats
hp = 4;
maxHp = 4;
extraHp = 4;
extraMaxhp = 4;
Step Event:
/// @description Execute Code\n
if keyboard_check_pressed(vk_down){
if extraHp < 1 {
hp --
}
else{
extraHp --
}
}
if keyboard_check_pressed(vk_up) {
if hp != maxHp {
hp ++
}
else{
extraHp ++
}
}
hp = clamp(hp,0,maxHp);
extraHp = clamp(extraHp,0,extraMaxhp);
if keyboard_check_pressed(vk_left) {
extraMaxhp --
}
if keyboard_check_pressed(vk_right) {
extraMaxhp ++
}
extraMaxhp = clamp(extraMaxhp,0,20)
Draw GUI Event:
/// @description Draw Hearts
draw_sprite(spr_heart,hp,xstart,ystart );
for (var i = 0; i < extraMaxhp; i++){
draw_sprite(spr_extrahp_empty, 0, xstart+65+(28*i),ystart+40*(extraMaxhp%2))
}
for (var i = 0; i < extraHp; i++){
draw_sprite(spr_extrahp_full, 0, xstart+65+(28*i),ystart+40)
}
Attachments
-
6.4 KB Views: 4