Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var aQTexts = ["Damn, I would bang the professor" , "DAT ASS ;)" , "So smart"];
- var bQTexts = ["Not perfect but well above average" , "Almost my favorite professor" , "I wonder what color his undies are"];
- var cQTexts = ["Pretty average, BORING" , "Lectures are a drag, but there is worse" , "Not bad"];
- var dQTexts = ["The professor smells" , "The professor is a dick" , "Needs to learn to teach"];
- var fQTexts = ["FUCK THE PROFESSOR, NOT THE GOOD KIND" , "How could someone suck so much" , "Just stop trying to teach"];
- //online comments
- var aQOnline = ["Super nice professor, also super hot" , "Can actually teach" , "Best professor ever"];
- var bQOnline = ["Really good professor, probably second best" , "Almost perfect" , "Really knows the material"];
- var cQOnline = ["Average professor" , "Goes through the motions, but not the worst" , "Not bad, I guess"];
- var dQOnline = ["Hard professor" , "Actually takes attendance, dick" , "He just sucks"];
- var fQOnline = ["STAY AWAY" , "Horrible professor" , "SUCKS ASS"];
- //interations
- var aQInteractions = ["Had coitus" , "Gave you his/her sisters number" , "Sent his/her mother over"];
- var bQInteractions = ["Compliments you daily" , "Brought you an apple" , "Blows kisses at you"];
- var cQInteractions = ["Show up to class on time " , "Turns on work most of the time" , "Never mean"];
- var dQInteractions = ["Only a tease" , "No reach around" , "Never called you back"];
- var fQInteractions = ["Turned you in after you hit on them" , "Spread rumors about your small genitals" , "Total dude-bro douche in class"];
- //first names
- //male first name
- var maleFName = ["Eric", "Ross", "Adam","Anthony", "CJ", "Chris", "Andrew", "Fred", "Steven", "Josh"];
- var femaleFName = ["Laura", "Denise", "Shella","Sara", "Michelle", "Bethany", "Lauren", "Leslie", "Abby"];
- var lastName = ["Hambone" , "Smellie", "Shufflebottom", "Dungworth", "Hardmeat", "Bottom", "Willy", "Turtle", "Hogwood", "Greedy", "Rattlebag", "Jelly", "Demon", "Nutters", "Cornfest", "Bonefat", "Steer", "Pigfat", "Piggs"];
- var grade = 0;
- var letterGrade = "z";
- var gameOn = true;
- var keyState = -1;
- var monstersCaught = 0;
- //actual vars
- var semesterOn = 1;
- var meterCount = 5;
- var gameState = "play";
- var correctlyGraded = 0;
- //creating and appending the canvas
- var canvas = document.createElement("canvas");
- var ctx = canvas.getContext("2d");
- canvas.width = 800;
- canvas.height = 600;
- document.body.appendChild(canvas);
- //loading a sound effect
- var snd = new Audio("audio/sample.wav");
- var no = new Audio("audio/no.wav");
- //sounds for letter grade
- var getA = new Audio("audio/getA.wav");
- var getB = new Audio("audio/getB.wav");
- var getC = new Audio("audio/getC.wav");
- var getD = new Audio("audio/getD.wav");
- var getF = new Audio("audio/getF.wav");
- //loading the images
- //bg image
- var bgReady = false;
- var bgImage = new Image();
- bgImage.onload = function ()
- {
- bgReady = true;
- }
- bgImage.src = "images/bgBP.png";
- //images for the game
- //comments
- var commentsReady = false;
- var commentsImage = new Image();
- commentsImage.onload = function ()
- {
- commentsReady = true;
- }
- commentsImage.src = "images/comments.png";
- //online
- var onlineReady = false;
- var onlineImage = new Image();
- onlineImage.onload = function ()
- {
- onlineReady = true;
- }
- onlineImage.src = "images/online.png";
- //interactions
- var interactionsReady = false;
- var interactionsImage = new Image();
- interactionsImage.onload = function ()
- {
- interactionsReady = true;
- }
- interactionsImage.src = "images/interactions.png";
- //grade decals
- var aReady = false;
- var aImage = new Image();
- aImage.onload = function ()
- {
- aReady = true;
- }
- aImage.src = "images/a.png";
- var bReady = false;
- var bImage = new Image();
- bImage.onload = function ()
- {
- bReady = true;
- }
- bImage.src = "images/b.png";
- var cReady = false;
- var cImage = new Image();
- cImage.onload = function ()
- {
- cReady = true;
- }
- cImage.src = "images/c.png";
- var dReady = false;
- var dImage = new Image();
- dImage.onload = function ()
- {
- dReady = true;
- }
- dImage.src = "images/d.png";
- var fReady = false;
- var fImage = new Image();
- fImage.onload = function ()
- {
- fReady = true;
- }
- fImage.src = "images/f.png";
- var controlsReady = false;
- var controlsImage = new Image();
- controlsImage.onload = function ()
- {
- controlsReady = true;
- }
- controlsImage.src = "images/controls.png";
- var testReady = false;
- var testImage = new Image();
- testImage.onload = function (){
- testReady = true;
- }
- testImage.src = "images/test.png";
- var quizReady = false;
- var quizImage = new Image();
- quizImage.onload = function (){
- quizReady = true;
- }
- quizImage.src = "images/quiz.png";
- var paperReady = false;
- var paperImage = new Image();
- paperImage.onload = function (){
- paperReady = true;
- }
- paperImage.src = "images/paper.png";
- //id images(8 of em)
- var idBoyOneReady = false;
- var idBoyOneImage = new Image();
- idBoyOneImage.onload = function ()
- {
- idBoyOneReady = true;
- }
- idBoyOneImage.src = "images/boyOne.png";
- var idBoyTwoReady = false;
- var idBoyTwoImage = new Image();
- idBoyTwoImage.onload = function ()
- {
- idBoyTwoReady = true;
- }
- idBoyTwoImage.src = "images/boyTwo.png";
- var idBoyThreeReady = false;
- var idBoyThreeImage = new Image();
- idBoyThreeImage.onload = function ()
- {
- idBoyThreeReady = true;
- }
- idBoyThreeImage.src = "images/boyThree.png";
- var idBoyFourReady = false;
- var idBoyFourImage = new Image();
- idBoyFourImage.onload = function ()
- {
- idBoyFourReady = true;
- }
- idBoyFourImage.src = "images/boyFour.png";
- //load female ID's
- var idGirlOneReady = false;
- var idGirlOneImage = new Image();
- idGirlOneImage.onload = function ()
- {
- idGirlOneReady = true;
- }
- idGirlOneImage.src = "images/girlOne.png";
- var idGirlTwoReady = false;
- var idGirlTwoImage = new Image();
- idGirlTwoImage.onload = function ()
- {
- idGirlTwoReady = true;
- }
- idGirlTwoImage.src = "images/girlTwo.png";
- var idGirlThreeReady = false;
- var idGirlThreeImage = new Image();
- idGirlThreeImage.onload = function ()
- {
- idGirlThreeReady = true;
- }
- idGirlThreeImage.src = "images/girlThree.png";
- var idGirlFourReady = false;
- var idGirlFourImage = new Image();
- idGirlFourImage.onload = function ()
- {
- idGirlFourReady = true;
- }
- idGirlFourImage.src = "images/girlFour.png";
- //bad meter
- var badReady = false;
- var badImage = new Image();
- badImage.onload = function ()
- {
- badReady = true;
- }
- badImage.src = "images/bad.png";
- //fired text
- var firedReady = false;
- var firedImage = new Image();
- firedImage.onload = function ()
- {
- firedReady = true;
- }
- firedImage.src = "images/fired.png";
- var playReady = false;
- var playImage = new Image();
- playImage.onload = function ()
- {
- playReady = true;
- }
- playImage.src = "images/playAgain.png";
- var titleReady = false;
- var titleImage = new Image();
- titleImage.onload = function ()
- {
- titleReady = true;
- }
- titleImage.src = "images/title.png";
- var howReady = false;
- var howImage = new Image();
- howImage.onload = function ()
- {
- howReady = true;
- }
- howImage.src = "images/how.png";
- var playFReady = false;
- var playFImage = new Image();
- playFImage.onload = function ()
- {
- playFReady = true;
- }
- playFImage.src = "images/playF.png";
- var theTextReady = false;
- var theTextImage = new Image();
- theTextImage.onload = function ()
- {
- theTextReady = true;
- }
- theTextImage.src = "images/theText.png";
- //objects for the studnet
- var student = {
- sex: "",
- fName: "",
- lName: "",
- iDent: "",
- comment: "",
- commentQ: "",
- onlineComment: "",
- onlineCommentQ: "",
- interaction: "",
- interactionQ: "",
- assignment: ""
- };
- //objects for the text-images
- var comments = {
- x: 0,
- y: 100
- };
- var online = {
- x: 0,
- y: 250
- };
- var interactions = {
- x: 0,
- y: 450
- };
- //objects for grade decals
- var a = {
- x: 300,
- y: 550
- };
- var b = {
- x: 350,
- y: 550
- };
- var c = {
- x: 400,
- y: 550
- };
- var d = {
- x: 450,
- y: 550
- };
- var f = {
- x: 500,
- y: 550
- };
- var controls = {
- x: 120,
- y: 560
- };
- //class work objects
- var test = {
- x: 300,
- y: 150
- };
- //objetcs for picture id's
- var boyOne = {
- x: 650,
- y: 60
- };
- //obejcts for the positions of the texts/comments/interations
- var textPos = {
- x:20,
- y:135
- };
- var onlinePos = {
- x:20,
- y:300
- };
- var interactionPos = {
- x:20,
- y:485
- };
- var bad = {
- x:290,
- y:532
- };
- var studentPos = {
- x:565,
- y:177
- };
- var semesterPos = {
- x:435,
- y:73
- };
- //player input
- var keysDown = {};
- addEventListener("keydown", function (e) {
- keysDown[e.keyCode] = true;
- }, false);
- addEventListener("keyup", function (e) {
- delete keysDown[e.keyCode];
- }, false);
- //initiate a new game(resets the hero position and the player position)
- var reset = function (){
- }
- var updateSemester = function() {
- if (correctlyGraded % 4 == 0 && correctlyGraded != 0)
- {
- semesterOn++;
- correctlyGraded = 0;
- }
- }
- //update the game objects
- var update = function (modifier) {
- //a = 65
- //b = 66
- //c = 67
- //d = 68
- //f = 70
- //check for keys pressed
- if (gameOn){
- if (65 in keysDown) {
- gameOn = false;
- keyState = 65;
- if (letterGrade != 'a'){
- meterCount--;
- no.play();
- }
- else {
- snd.play();
- getA.play();
- correctlyGraded++;
- }
- }
- if (66 in keysDown) {
- gameOn = false;
- keyState = 66;
- if (letterGrade != 'b'){
- meterCount--;
- no.play();
- }
- else {
- snd.play();
- getB.play();
- correctlyGraded++;
- }
- }
- if (67 in keysDown) {
- gameOn = false;
- keyState = 67;
- if (letterGrade != 'c'){
- meterCount--;
- no.play();
- }
- else {
- snd.play();
- getC.play();
- correctlyGraded++;
- }
- }
- if (68 in keysDown) {
- gameOn = false;
- keyState = 68;
- if (letterGrade != 'd'){
- meterCount--;
- no.play();
- }
- else {
- snd.play();
- getD.play();
- correctlyGraded++;
- }
- }
- if (70 in keysDown) {
- gameOn = false;
- keyState = 70;
- if (letterGrade != 'f'){
- meterCount--;
- no.play();
- }
- else {
- snd.play();
- getF.play();
- correctlyGraded++;
- }
- }
- }
- updateSemester();
- if (meterCount <= 0)
- gameState = "end";
- if (!gameOn && !(keyState in keysDown))
- continueGame();
- };
- var assignStudent = function (){
- //pick the gender of the student
- var r = Math.floor((Math.random() * 2) + 1);
- if (r == 1) {
- student.sex = "m";
- student.fName = maleFName[Math.floor((Math.random() * maleFName.length))] //pick male first name
- //assign id for males
- r = Math.floor((Math.random() * 4) + 1);
- if (r == 1) {
- student.iDent = idBoyOneImage;
- }
- else if (r == 2) {
- student.iDent = idBoyTwoImage;
- }
- else if (r == 3) {
- student.iDent = idBoyThreeImage;
- }
- else if (r == 4) {
- student.iDent = idBoyFourImage;
- }
- }
- else{
- student.sex = "f";
- student.fName = femaleFName[Math.floor((Math.random() * femaleFName.length))] //pick female first name
- //assign ID for females
- r = Math.floor((Math.random() * 4) + 1);
- if (r == 1) {
- student.iDent = idGirlOneImage;
- }
- else if (r == 2) {
- student.iDent = idGirlTwoImage;
- }
- else if (r == 3) {
- student.iDent = idGirlThreeImage;
- }
- else if (r == 4) {
- student.iDent = idGirlFourImage;
- }
- }
- //assign last name
- student.lName = lastName[Math.floor((Math.random() * lastName.length))] //pick female first name
- //pick assignment
- r = Math.floor((Math.random() * 3) + 1);
- if (r == 1){
- student.assignment = testImage;
- }
- else if (r == 2){
- student.assignment = quizImage;
- }
- else if (r == 3){
- student.assignment = paperImage;
- }
- //pick comment quality
- r = Math.floor((Math.random() * 5) + 1);
- if (r == 1) {
- student.commentQ = 55;
- student.comment = fQTexts[Math.floor((Math.random() * fQTexts.length))];
- }
- else if (r == 2) {
- student.commentQ = 65;
- student.comment = dQTexts[Math.floor((Math.random() * dQTexts.length))];
- }
- else if (r == 3) {
- student.commentQ = 75;
- student.comment = cQTexts[Math.floor((Math.random() * cQTexts.length))];
- }
- else if (r == 4) {
- student.commentQ = 85;
- student.comment = bQTexts[Math.floor((Math.random() * bQTexts.length))];
- }
- else if (r == 5){
- student.commentQ = 95;
- student.comment = aQTexts[Math.floor((Math.random() * aQTexts.length))];
- }
- //pick online comments
- r = Math.floor((Math.random() * 5) + 1);
- if (r == 1) {
- student.onlineCommentQ = 55;
- student.onlineComment = fQOnline[Math.floor((Math.random() * fQOnline.length))];
- }
- else if (r == 2) {
- student.onlineCommentQ = 65;
- student.onlineComment = dQOnline[Math.floor((Math.random() * dQOnline.length))];
- }
- else if (r == 3) {
- student.onlineCommentQ = 75;
- student.onlineComment= cQOnline[Math.floor((Math.random() * cQOnline.length))];
- }
- else if (r == 4) {
- student.onlineCommentQ = 85;
- student.onlineComment = bQOnline[Math.floor((Math.random() * bQOnline.length))];
- }
- else if (r == 5){
- student.onlineCommentQ = 95;
- student.onlineComment = aQOnline[Math.floor((Math.random() * aQOnline.length))];
- }
- //pick interaction
- r = Math.floor((Math.random() * 5) + 1);
- if (r == 1) {
- student.interactionQ = 55;
- student.interaction = fQInteractions[Math.floor((Math.random() * fQInteractions.length) )];
- }
- else if (r == 2) {
- student.interactionQ = 65;
- student.interaction = dQInteractions[Math.floor((Math.random() * dQInteractions.length))];
- }
- else if (r == 3) {
- student.interactionQ = 75;
- student.interaction = cQInteractions[Math.floor((Math.random() * cQInteractions.length))];
- }
- else if (r == 4) {
- student.interactionQ = 85;
- student.interaction = bQInteractions[Math.floor((Math.random() * bQInteractions.length))];
- }
- else if (r == 5){
- student.interactionQ = 95;
- student.interaction = aQInteractions[Math.floor((Math.random() * aQInteractions.length))];
- }
- }
- var calcGrade = function() {
- grade = (student.commentQ + student.onlineCommentQ + student.interactionQ)/3;
- if (grade < 60)
- letterGrade = "f";
- else if (grade < 70)
- letterGrade = "d";
- else if (grade < 80)
- letterGrade = "c";
- else if (grade < 90)
- letterGrade = "b";
- else if (grade <= 100)
- letterGrade = "a";
- }
- var continueGame = function () {
- gameOn = true;
- assignStudent();
- calcGrade();
- console.log(grade);
- }
- //actual game reset
- var gameGo = function () {
- //the game has started
- semesterOn = 1;
- keyState = -1;
- meterCount = 5;
- grade = 0;
- letterGrade = "z";
- gameState = "start"; //reset the game state
- correctlyGraded = 0;
- continueGame();
- }
- var gameGoS = function () {
- //the game has started
- semesterOn = 1;
- keyState = -1;
- meterCount = 5;
- grade = 0;
- letterGrade = "z";
- gameState = "play"; //reset the game state
- correctlyGraded = 0;
- continueGame();
- }
- //draw the objects
- // Draw everything
- var render = function () {
- if (bgReady) {
- ctx.drawImage(bgImage, 0, 0);
- }
- //actual game rendering
- //render the text-images
- if (commentsReady) {
- ctx.drawImage(commentsImage, comments.x, comments.y);
- }
- if (onlineReady) {
- ctx.drawImage(onlineImage, online.x, online.y);
- }
- if (interactionsReady) {
- //ctx.rotate(Math.PI / 180 * 3); //increment the angle and rotate the image
- ctx.drawImage(interactionsImage, interactions.x, interactions.y);
- }
- //render the grade decals
- if (aReady) {
- //ctx.rotate(Math.PI / 180 * 3); //increment the angle and rotate the image
- ctx.drawImage(aImage, a.x, a.y);
- }
- if (bReady) {
- //ctx.rotate(Math.PI / 180 * 3); //increment the angle and rotate the image
- ctx.drawImage(bImage, b.x, b.y);
- }
- if (cReady) {
- //ctx.rotate(Math.PI / 180 * 3); //increment the angle and rotate the image
- ctx.drawImage(cImage, c.x, c.y);
- }
- if (dReady) {
- //ctx.rotate(Math.PI / 180 * 3); //increment the angle and rotate the image
- ctx.drawImage(dImage, d.x, d.y);
- }
- if (fReady) {
- //ctx.rotate(Math.PI / 180 * 3); //increment the angle and rotate the image
- ctx.drawImage(fImage, f.x, f.y);
- }
- //controls image
- if (controlsReady) {
- //ctx.rotate(Math.PI / 180 * 3); //increment the angle and rotate the image
- ctx.drawImage(controlsImage, controls.x, controls.y);
- }
- //class work images
- if (testReady && paperReady && quizReady) {
- ctx.drawImage(student.assignment, test.x, test.y);
- }
- //check that all picture ID's are ready
- if (idBoyOneReady && idBoyTwoReady && idBoyThreeReady && idBoyFourReady && idBoyFourReady && idGirlOneReady &&
- idGirlTwoReady && idGirlThreeReady && idGirlFourReady) {
- //ctx.rotate(Math.PI / 180 * 3); //increment the angle and rotate the image
- ctx.drawImage(student.iDent, boyOne.x, boyOne.y);
- }
- //drawing the bad meter
- if (badReady) {
- //ctx.rotate(Math.PI / 180 * 3); //increment the angle and rotate the image
- var temp = 0;
- for (var i = 0; i < meterCount; i++)
- {
- ctx.drawImage(badImage, bad.x + temp, bad.y);
- temp += 20;
- }
- }
- //title
- ctx.fillStyle = "rgb(0, 0, 0)";
- ctx.font = "24px Lucida Console";
- ctx.textAlign = "left";
- ctx.textBaseline = "top";
- ctx.fillText("Bad Professor",300,32);
- //semester
- ctx.fillStyle = "rgb(0, 0, 0)";
- ctx.font = "20px Lucida Console";
- ctx.textAlign = "left";
- ctx.textBaseline = "top";
- ctx.fillText("Semester: ",320,70);
- //student name text
- ctx.fillStyle = "rgb(0, 0, 0)";
- ctx.font = "20px Lucida Console";
- ctx.textAlign = "left";
- ctx.textBaseline = "top";
- ctx.fillText("Student name: ",400,175);
- //comments,online,interations
- //comments
- //A 57 191 69
- //B 54 236 213
- //C 250 249 9
- //D 73 65 46
- //F 231 77, 62
- if (student.commentQ == 55)
- {
- ctx.fillStyle = "rgb(231,77,62)";
- }
- else if (student.commentQ == 65) {
- ctx.fillStyle = "rgb(73, 65, 46)";
- }
- else if (student.commentQ == 75) {
- ctx.fillStyle = "rgb(250, 249, 9)";
- }
- else if (student.commentQ == 85) {
- ctx.fillStyle = "rgb(54, 236, 213)";
- }
- else if (student.commentQ == 95) {
- ctx.fillStyle = "rgb(57, 191, 69)";
- }
- ctx.fillStyle = "rgb(0, 0, 0)";
- // ctx.fillStyle = "rgb(57,191, 69)";
- ctx.font = "15px Lucida Console";
- ctx.textAlign = "left";
- ctx.textBaseline = "top";
- ctx.fillText(student.comment,textPos.x,textPos.y);
- if (student.onlineCommentQ == 55)
- {
- ctx.fillStyle = "rgb(231,77,62)";
- }
- else if (student.onlineCommentQ == 65) {
- ctx.fillStyle = "rgb(73, 65, 46)";
- }
- else if (student.onlineCommentQ== 75) {
- ctx.fillStyle = "rgb(250, 249, 9)";
- }
- else if (student.onlineCommentQ == 85) {
- ctx.fillStyle = "rgb(54, 236, 213)";
- }
- else if (student.onlineCommentQ == 95) {
- ctx.fillStyle = "rgb(57, 191, 69)";
- }
- ctx.fillStyle = "rgb(0, 0, 0)";
- //online
- //ctx.fillStyle = "rgb(57,191, 69)";
- ctx.font = "15px Lucida Console";
- ctx.textAlign = "left";
- ctx.textBaseline = "top";
- ctx.fillText(student.onlineComment,onlinePos.x,onlinePos.y);
- if (student.interactionQ == 55)
- {
- ctx.fillStyle = "rgb(231,77,62)";
- }
- else if (student.interactionQ == 65) {
- ctx.fillStyle = "rgb(73, 65, 46)";
- }
- else if (student.interactionQ == 75) {
- ctx.fillStyle = "rgb(250, 249, 9)";
- }
- else if (student.interactionQ == 85) {
- ctx.fillStyle = "rgb(54, 236, 213)";
- }
- else if (student.interactionQ == 95) {
- ctx.fillStyle = "rgb(57, 191, 69)";
- }
- ctx.fillStyle = "rgb(0, 0, 0)";
- //interactions
- // ctx.fillStyle = "rgb(57,191, 69)";
- ctx.font = "15px Lucida Console";
- ctx.textAlign = "left";
- ctx.textBaseline = "top";
- ctx.fillText(student.interaction,interactionPos.x,interactionPos.y);
- //bad meter text
- ctx.fillStyle = "rgb(0,0, 0)";
- ctx.font = "15px Lucida Console";
- ctx.textAlign = "left";
- ctx.textBaseline = "top";
- ctx.fillText("Bad meter: " , 190,540);
- //student name text box
- ctx.fillStyle = "rgb(0,0, 0)";
- ctx.font = "15px Lucida Console";
- ctx.textAlign = "left";
- ctx.textBaseline = "top";
- ctx.fillText(student.fName + " " + student.lName, studentPos.x,studentPos.y);
- //number semester text
- ctx.fillStyle = "rgb(0,0, 0)";
- ctx.font = "15px Lucida Console";
- ctx.textAlign = "left";
- ctx.textBaseline = "top";
- ctx.fillText(semesterOn, semesterPos.x,semesterPos.y);
- };
- var updateEnd = function() {
- //look for spacebar (32), if space bar pressed, restart the game
- if (32 in keysDown) {
- gameGo();
- }
- }
- var renderEnd = function() {
- //clear screen
- if (bgReady) {
- ctx.drawImage(bgImage, 0, 0);
- }
- if (firedReady) {
- ctx.drawImage(firedImage, 257,250);
- }
- if (playReady) {
- ctx.drawImage(playImage, 260,315);
- }
- }
- var updateStart = function () {
- if (32 in keysDown) {
- gameGoS();
- }
- }
- var renderStart = function() {
- //clear screen
- if (bgReady) {
- ctx.drawImage(bgImage, 0, 0);
- }
- if (titleReady) {
- ctx.drawImage(titleImage, 255, 200);
- }
- if (howReady) {
- ctx.drawImage(howImage, 265, 250);
- }
- if (theTextReady){
- ctx.drawImage(theTextImage, 240, 230);
- }
- if (playFReady) {
- ctx.drawImage(playFImage, 260,550);
- }
- }
- //main game loop
- var main = function () {
- var now = Date.now();
- var delta = now - then;
- if (gameState == "play"){
- update(delta / 1000); //call to update
- render(); //call to render
- }
- //update and render the end screen
- else if (gameState == "end") {
- updateEnd(); //call to update
- renderEnd(); //call to render
- }
- else if (gameState == "start") {
- updateStart(); //call to update
- renderStart(); //call to render
- }
- then = now;
- // Request to do this again ASAP
- requestAnimationFrame(main);
- };
- // Cross-browser support for requestAnimationFrame
- var w = window;
- requestAnimationFrame = w.requestAnimationFrame || w.webkitRequestAnimationFrame || w.msRequestAnimationFrame || w.mozRequestAnimationFrame;
- //start the game
- // Let's play this game!
- var then = Date.now();
- reset();
- gameGo();
- main();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement