192 : Player life status
Balthazar:
Copy the player icon file into the images/player directory.
Copy the following files into your project:
function init_game() {
...
// Status images
_game.img_key = new Image();
_game.img_key.src = _game.imagedir_items + "key.png";
_game.img_player = new Image();
_game.img_player.src = _game.imagedir_player + "icon.png";
}
function draw_status(ctx) {
var health = (_game.meter_width * _player.health) / _player.health_max;
ctx.fillStyle = "rgba(0,255,0, 0.5)";
ctx.fillRect(_game.meter_x, _game.meter_y, health, _game.meter_height);
ctx.strokeStyle = "black";
ctx.strokeRect(_game.meter_x, _game.meter_y, _game.meter_width, _game.meter_height);
// If the player has the key, draw it in the status area.
var level = _levels[_game.current_level];
if (level.player_has_key) {
ctx.drawImage(_game.img_key, _game.meter_width + 15, 11);
}
// Draw player icons to indicate how many extra lives remain.
for (var i = 0; i < _game.player_lives-1; i++) {
ctx.drawImage(_game.img_player, _game.width - 30 - (i * 20), 12);
}
}
GOTO 134 if you NOT have the Treasure I - Key badge.
GOTO 100