Esempio n. 1
0
	constructor() {
		// Create a new image
		this.menu = new Image();
		this.menu.src = "img/mainSheet.png";

		if (window.Link) {
			this.hearts = Link.hearts;
			this.bombs = Link.bombs;
			this.arrow = Link.arrow;
		}

		this.tick = 0;

		// Check if Start Menu is closed
		this.lockControls = false;
		// Take away Link's controls
		Keyboard.withContext("Player", () => {
			Keyboard.bind('enter', () => {
				Keyboard.setContext("Menu_Opening");
			});
		});

		// Change context to Menu_Closing if entire Start Menu is open. Close menu in update()
		Keyboard.withContext("Menu_Opening", () => {
			Keyboard.bind(['enter', 'a', 's', 'd', 'w', 'shift'], () => {
				this.lockControls = true;
				if (this.tick === SCROLL_DISTANCE) {
					Keyboard.setContext("Menu_Closing");
				}
			});
		});

	}
Esempio n. 2
0
	constructor() {
		// Create the music elements for the screen
		this.music = {
			"rain": new Howl({
				src: ["/sounds/weather/rain.m4a"],
				autoplay: true,
				loop: true,
				volume: 0.3
			}),
			"openingDemo": new Howl({
				src: ["/music/lightWorld/introDemo/openingDemo.m4a"],
				volume: 0.5,
				sprite: {
					intro: [0, 6800]
				},
				onend: () => {
					this.music.openingDemoRise.play("rise");
				}
			}),
			"openingDemoRise": new Howl({
				src: ["/music/lightWorld/introDemo/openingDemo.m4a"],
				volume: 0.5,
				sprite: {
					rise: [6800, 27141, true]
				}
			})
		};

		this.uncle = new NPC("UNCLE", 3);
		this.uncle.setLevelObjects(new OBJECTS());
		this.uncle.setCurrentAction("SITTING", "DOWN");
		this.uncle.setPosition(165, 85);

		Player.setLevelObjects(new OBJECTS());
		Player.actions("STAND", "RIGHT");
		Player.setPosition(90, 75);

		this.storyStateIndex = 0;
		this.initialState();

		this.currentStrokes = new Map();

		this.counter = 0;

		// Setup the key bindings
		Keyboard.withContext("level", () => {
			Keyboard.bind(["a", "s", "d", "w", "enter"], () => {
				if (this.storyStateIndex === 2) {
					Animate.uncleWalking(this.uncle);
					this.storyState.shift();
					this.storyStateIndex++;
				} else if (this.storyStateIndex === 3) {
					if (!Animate.isAnimating()) {
						Animate.linkJumpingOffBed(56, 66);
						this.storyState.shift();
						this.storyStateIndex++;
					}
				}
			});
		});

		// Display the dialogue text
		Text.setScrollText(DIALOGUE.SCROLL, 38, 145);

		Canvas.addEventListener('OFFMAP', () => State.popAndPush(new LinksHouse()) , false);
	}