490 : Adding eyeball monsters

Balthazar:

To add monster eyes that peek out from the platforms, we'll first need 3 eye images.

eyes0.png

eyes1.png

eyes2.png

Copy the following files into your project:

function init_level3() { ... // Create the monsters. var monster_data = [ ... ]; add_monsters(level, monster_data); var eyes1 = [ [110, 200], [540, 300], [120, 55], [130, 280], [10, 180], [350, 260], ]; add_eyeball_monsters(level, eyes1, 200, 100, 10); var eyes2 = [ [390, 180], [270, 220], [490, 240], [510, 140], [290, 280], [10, 220], [250, 140], [180, 55], ]; add_eyeball_monsters(level, eyes2, 450, 100, 10); ... }
function add_projectile_monsters(level, monster_data) { ... } function add_eyeball_monsters(level, eyes, pause, open, close) { var num_eyes = eyes.length; var blink_duration = open + close + open; var eye_loop = num_eyes * (blink_duration + pause); for (var i = 0; i < num_eyes; i++) { var sprites = []; var start_delay = pause/2 + (i * (blink_duration + pause)); sprites.push(["eyes0", start_delay]); sprites.push(["eyes1", open]); sprites.push(["eyes2", close]); sprites.push(["eyes1", open]); sprites.push(["eyes0", eye_loop - blink_duration - start_delay]); var monst = create_monster(eyes[i][0], eyes[i][1], 20, 20, 0, 550, 0, sprites); level.monsters.push(monst); } }

GOTO 495