function init() {
	// Initialize constants
	var canvas = document.getElementById("gamespace"),
		stage = new createjs.Stage(canvas),
		// Setup the background image
		bg = new createjs.Bitmap("img/starfield.png"),
		// Setup the Star Wars logo image
		logo = new createjs.Bitmap("img/logo.png"),
		// Setup the start button
		startButton = new createjs.Bitmap("img/START-GAME.png"),
		// Setup the continue button
		continueButton = new createjs.Bitmap("img/continue.png"),
		// Correct Answer Image
		rightAnswer = new createjs.Bitmap("img/right-answer.png"),
		// Wrong Answer Image
		wrongAnswer = new createjs.Bitmap("img/wrong-answer.png"),
	    nextQbutton = new createjs.Bitmap("img/next-question.png"),
	    // Images for Question 1
	    ewok = new createjs.Bitmap("img/ewok.png"),
		wookie = new createjs.Bitmap("img/wookie.png"),
		gungan = new createjs.Bitmap("img/gungan.png"),
		// Images for Question 2
		shmi = new createjs.Bitmap("img/shmi-skywalker.png"),
		mon = new createjs.Bitmap("img/mon-mothma.png"),
		tuan = new createjs.Bitmap("img/tuan-we.png");
		// Images for Question 3
		sidious = new createjs.Bitmap("img/darth-sidious.png"),
		vader = new createjs.Bitmap("img/darth-vader.png"),
		dooku = new createjs.Bitmap("img/count-dooku.png"),
		// Good ending screen
		endGood = new createjs.Bitmap("img/good-ending.png"),
		// Bad ending screen
		endBad = new createjs.Bitmap("img/bad-ending.png"),
		centerX = canvas.width/2,
		centerY = canvas.height/2,
		logoSizeX = 200,
		inst = new createjs.Text(),
		assetsPath = "snd/",
	  	// load in all of the sounds for the game
	    manifest = [{src:assetsPath+"Theme - Star Wars.mp3|"+assetsPath+"Theme - Star Wars.ogg", id:"theme"},
	    	{src:assetsPath+"blaster.mp3|"+assetsPath+"blaster.ogg", id:"buttonSnd"},
	    	{src:assetsPath+"powrweak.mp3|"+assetsPath+"powrweak.ogg", id:"powerWeak"},
	    	{src:assetsPath+"cocky.mp3|"+assetsPath+"cocky.ogg", id:"cocky"},
	    	{src:assetsPath+"haveyou.mp3|"+assetsPath+"haveyou.ogg", id:"haveYou"},
	    	{src:assetsPath+"strong.mp3|"+assetsPath+"strong.ogg", id:"strong"}],
	   	// Get the position of the questions
	   	questionPosition = 0,
	   	// Keep track of the number of correct answers
	   	numCorrect = 0,
	   	// Keep track of the number of wrong answers
	   	numWrong = 0,
	    // Question Area and Question Text
	    qArea = new createjs.Shape(),
	    // Questions
	    q1 = "Which of these is a Wookie?",
	    q2 = "Which one is Anakin Skywalker's mother?",
	    q3 = "Who trained Darth Maul in the Jedi Arts?",
	    // Correct Message Text
	    correctMsg = new createjs.Text(),
	    // Wrong Message Text
	    wrongMsg = new createjs.Text(),
		// Question Text 
		q = new createjs.Text(),
		queue = new createjs.LoadQueue(false);

	// Preload all the images with PreloadJS
	queue.loadManifest(["img/starfield.png", 
		"img/logo.png",
		"img/START-GAME.png",
		"img/continue.png",
		"img/right-answer.png",
		"img/wrong-answer.png",
		"img/next-question.png",
		"img/ewok.png",
		"img/wookie.png",
		"img/gungan.png",
		"img/shmi-skywalker.png",
		"img/mon-mothma.png",
		"img/tuan-we.png",
		"img/darth-sidious.png",
		"img/darth-vader.png",
		"img/count-dooku.png",
		"img/good-ending.png",
		"img/bad-ending.png"]);
	queue.load();	
	queue.addEventListener("complete", showManifest);
	queue.addEventListener("progress", showProgress);
	function showProgress(evt) {
		var perc = evt.loaded / evt.total;
		console.log(Math.ceil(perc*100).toString());
	}
	function showManifest() {
		console.log("Files are loaded");
	}

		
	
	// Play the theme song	
    createjs.Sound.addEventListener("fileload", createjs.proxy(soundLoaded, this));
    createjs.Sound.registerManifest(manifest);
    createjs.Sound.play("theme");

    function soundLoaded(event) {
        console.log("sounds loaded");
    }


	bg.x = 0;
	bg.y = 0;

	logo.regX = 396;
	logo.regY = 175;

	stage.addChild(bg,logo);

	logo.alpha = 1;
	createjs.Tween.get(logo).to({alpha: 0},3600).call(onComplete);

	
	// Create the opening animation
	createjs.Ticker.setFPS(30);
	createjs.Ticker.addEventListener("tick", startAnim);
	function startAnim(e) {	
		logo.x = centerX;
		logo.y = centerY;
		logo.scaleX -= 0.005;
		logo.scaleY -= 0.005;
		
		stage.update();
	}
	function onComplete() {
		removeEventListener("tick", startAnim);
		stage.addChild(startButton);
		createjs.Tween.get(startButton).to({y:370}, 1000);
		startButton.x = 245;
		startButton.y = 620;
		
		inst.text = "Welcome to the Star Wars Guessing Game. This game will test if\n you are a true Star Wars fan. In the next few screens, you will be shown some\n images from the Star Wars Universe. Identify the correct image to advance.\n If not, the Empire takes over the Galaxy.\n\n May the force be with you.";
		inst.font = "normal 24px Myriad Pro, 'MyriadPro', sans-serif";
		inst.color = "#298FC2";
		inst.linewidth = 200;
		inst.textAlign = "center";
		inst.textBaseline = "top";
		
		inst.lineHeight = 26;

		inst.x = centerX;
		inst.y = 180;

		stage.addChild(inst);	
		inst.alpha = 0;
		createjs.Tween.get(inst).to({alpha:1},1000);	

		stage.update();

	}
	function question1() {
		questionPosition++; // Initialize Question Position
		stage.removeChild(inst,startButton);
		
		qArea.graphics.beginStroke("#298FC2");
		qArea.graphics.setStrokeStyle(10,0,1);
		qArea.graphics.beginFill("#ffffff");
		qArea.graphics.drawRoundRect(50, 87, 700, 425, 10);

		stage.addChild(qArea);

		stage.addChild(ewok);
		ewok.alpha = 0;
		createjs.Tween.get(ewok).to({alpha: 1},500);
		ewok.x = 70;
		ewok.y = 150;
		stage.addChild(wookie);
		wookie.alpha = 0;
		createjs.Tween.get(wookie).to({alpha: 1},500);
		wookie.x = 290;
		wookie.y = 150;
		stage.addChild(gungan);
		gungan.alpha = 0;
		createjs.Tween.get(gungan).to({alpha: 1},500);
		gungan.x = 510;
		gungan.y = 150;

		q.text = q1;
		q.font = "normal 24px Myriad Pro, 'MyriadPro', sans-serif";
		q.color = "#298FC2";
		q.textAlign = "center";

		stage.addChild(q);
		q.x = 400;
		q.y = 450;

		ewok.onClick = function() {
			answerWrong();
		}
		gungan.onClick = function() {
			answerWrong();
		}
		wookie.onClick = function() {
			answerCorrect();
		}

		stage.update();	
	}
	function question2() {
		questionPosition++;
		// For Garbage Collection
		stage.removeChild(nextQbutton,ewok,wookie,gungan);
		// Function that removes correct or incorrect Answer Screen
		clearScreen();
		stage.addChild(shmi);
		shmi.alpha = 0;
		createjs.Tween.get(shmi).to({alpha: 1},500);
		shmi.x = 70;
		shmi.y = 150;
		stage.addChild(mon);
		mon.alpha = 0;
		createjs.Tween.get(mon).to({alpha: 1},500);
		mon.x = 290;
		mon.y = 150;
		stage.addChild(tuan);
		tuan.alpha = 0;
		createjs.Tween.get(tuan).to({alpha: 1},500);
		tuan.x = 510;
		tuan.y = 150;

		q.text = q2;
		q.font = "normal 24px Myriad Pro, 'MyriadPro', sans-serif";
		q.color = "#298FC2";
		q.textAlign = "center";

		stage.addChild(q);
		q.x = 400;
		q.y = 450;

		mon.onClick = function() {
			answerWrong();
		}
		tuan.onClick = function() {
			answerWrong();
		}
		shmi.onClick = function() {
			answerCorrect();
		}
		stage.update();	
	}
	function question3() {
		questionPosition++;
		// For Garbage Collection
		stage.removeChild(nextQbutton,mon,tuan,shmi);
		// Function that removes correct or incorrect Answer Screen
		clearScreen();
		
		stage.addChild(vader);
		vader.alpha = 0;
		createjs.Tween.get(vader).to({alpha: 1},500);
		vader.x = 70;
		vader.y = 150;
		stage.addChild(dooku);
		dooku.alpha = 0;
		createjs.Tween.get(dooku).to({alpha: 1},500);
		dooku.x = 290;
		dooku.y = 150;
		stage.addChild(sidious);
		sidious.alpha = 0;
		createjs.Tween.get(sidious).to({alpha: 1},500);
		sidious.x = 510;
		sidious.y = 150;

		q.text = q3;
		q.font = "normal 24px Myriad Pro, 'MyriadPro', sans-serif";
		q.color = "#298FC2";
		q.textAlign = "center";

		stage.addChild(q);
		q.x = 400;
		q.y = 450;

		vader.onClick = function() {
			answerWrong();
		}
		dooku.onClick = function() {
			answerWrong();
		}
		sidious.onClick = function() {
			answerCorrect();
		}
		stage.update();	
	}
	function answerCorrect() {
		// console.log("The force is strong with this one!");
		createjs.Sound.play("strong");
		questionCorrect = true;
		numCorrect++;
		stage.addChild(rightAnswer);
		rightAnswer.x = 50;
		rightAnswer.y = 87;
		
		correctMsg.text = "The force is strong with this one!";
		correctMsg.font = "normal 24px Myriad Pro, 'MyriadPro', sans-serif";
		correctMsg.color = "#298FC2";
		correctMsg.textAlign = "center";
		stage.addChild(correctMsg);
		correctMsg.x = 400;
		correctMsg.y = 450;
		
		if(questionPosition<3) {
			stage.addChild(nextQbutton);
			nextQbutton.regX = 384/2;
			nextQbutton.regY = 56/2;
			nextQbutton.x = centerX;
			nextQbutton.y = 520;
		}

		if(questionPosition==3) {
	    	continueFinal();
	    }
	}
	function answerWrong() {
		createjs.Sound.play("haveYou");
		questionCorrect = false;
		numWrong++;
		stage.addChild(wrongAnswer);
		wrongAnswer.x = 50;
		wrongAnswer.y = 87;

		wrongMsg.text = "I have you now!";
		wrongMsg.font = "normal 24px Myriad Pro, 'MyriadPro', sans-serif";
		wrongMsg.color = "#298FC2";
		wrongMsg.textAlign = "center";
		stage.addChild(wrongMsg);
		wrongMsg.x = 400;
		wrongMsg.y = 450;
		
		if(questionPosition<3) {
			stage.addChild(nextQbutton);
			nextQbutton.regX = 384/2;
			nextQbutton.regY = 56/2;
			nextQbutton.x = centerX;
			nextQbutton.y = 520;
		}

		if(questionPosition==3) {
	    	continueFinal();
	    } 
    	
	    
	}
	function continueFinal() {
		stage.addChild(continueButton);
    	continueButton.regX = 384/2;
		continueButton.regY = 56/2;
    	continueButton.x = centerX;
		continueButton.y = 0;
		continueButton.alpha = 0;
		createjs.Tween.get(continueButton).to({y:520, alpha: 1}, 1000);
		
		continueButton.onClick = function() {
			endGame();
		}
	}
	function clearScreen() {
		stage.removeChild(vader,sidious,dooku,nextQbutton);
		if(questionCorrect==true) {
			stage.removeChild(rightAnswer,correctMsg);
		} else {
			stage.removeChild(wrongAnswer,wrongMsg);
		}
	}
	function endGame() {
		clearScreen();
		stage.removeChild(continueButton);
		var results = new createjs.Text();
		results.text =  "";
		results.font = "normal 24px Myriad Pro, 'MyriadPro', sans-serif";
		results.color = "#298FC2";
		results.textAlign = "center";

		 if(numCorrect==3) {
		 	createjs.Sound.play("cocky");
	    	stage.addChild(endGood);
	    	endGood.x = 50;
	    	endGood.y = 87;
	    	
	    	results.text = "Great job kid, don't get too cocky!";
	    	stage.addChild(results);
			results.x = 400;
			results.y = 450;
	    } else {
	    	createjs.Sound.play("powerWeak");
	    	stage.addChild(endBad);
	    	endBad.x = 50;
	    	endBad.y = 87;

		    results.text = "Your powers are weak old man!";
		    stage.addChild(results);
		    results.x = 400;
		    results.y = 450;
	    }
	}
	startButton.onClick = function() {
		question1();
		createjs.Sound.play("buttonSnd");
	}
	nextQbutton.onClick = function() {
		createjs.Sound.play("buttonSnd");
		if(questionPosition==1) {
			question2();
		} else if(questionPosition==2) {
			question3();
		}
	}
	
}