113 : Unlocked goal image

Balthazar:

Get open/close image

Balthazar:

We need 2 images - one for the open gate and another for the closed gate.

gate-closed.png

gate-open.png

Copy the following files into your project:

Balthazar:

Since we'e changing the size of the goal, we need to update the width and height.

function create_goal(x, y, next_level) { var goal = {}; goal.x = x; goal.y = y; goal.width = 20; goal.width = 30; goal.height = 20; goal.height = 40; goal.origin_x = goal.width / 2; goal.origin_y = goal.height; goal.next_level = next_level; goal.img_open = new Image(); goal.img_open.src = _game.imagedir_backgrounds + "gate-open.png"; goal.img_closed = new Image(); goal.img_closed.src = _game.imagedir_backgrounds + "gate-closed.png"; return goal; }
function draw_goal(ctx) { var level = _levels[_game.current_level]; var goal = level.goal; ctx.fillStyle = "green"; ctx.fillRect(goal.x - goal.origin_x, goal.y - goal.origin_y, goal.width, goal.height); var image = goal.img_closed; if (level.player_has_key) { image = goal.img_open; } set_transform(ctx, goal); ctx.drawImage(image, 0, 0); reset_transform(ctx); }

GOTO 142