Easiest way would be having a timeout
then something like
PHP Code:
temp.img = "block.png";
showimg(200, img, 20, 20);
changeimgvis(200, 4);
changeimgpart(200, 0, 0, (player.hearts / player.fullhearts) * getimgwidth(img), getimgheight(img));
Pretty basic math.