Wednesday, March 26, 2014

Step 10 - Finalize game and tutorial

Step 10: Finalize game and tutorial

  • Finish up the game and resource


Score: 10



Evaluation & Deliverables:

This week I wrapped up the website. I made a tutorial to help users learn how to play the game. I used JavaScript and jQuery to make floating boxes that shifted around the screen to point out certain game features. I'm hoping the game makes sense to people. It's not exactly the most intuitive game. I almost feel like the game is an instance of Pavlov's conditioning--using punishments and rewards to help someone learn. Anyways, the instructional aspect may have some issues, but the game is up and running! The main point of the game is to help people learn a metaphor that may help them remember the purpose of different punctuation marks. Hopefully it helps!

Here's a link to the "finished" product: https://googledrive.com/host/0Bwuo-xxRHyjmOXZSZHA4YmVRSE0/punctuation_project/web_resource_mainpage.html 

Here's some scripting to run the tutorial:

function tutorialBoxNext() {
$('#comment').removeClass();
if(tutorialCount === 0) {
$('#comment').addClass('A');
document.getElementById("comment").innerHTML="<--This is Mark.";
tutorialCount++;
} else if (tutorialCount === 1) {
$('#comment').addClass('B');
document.getElementById("comment").innerHTML="This is one of Grammar's Thugs-->";
tutorialCount++;
} else if (tutorialCount === 2) {
$('#comment').addClass('C');
document.getElementById("comment").innerHTML="And so is he-->";
tutorialCount++;
} else if (tutorialCount === 3) {
$('#comment').addClass('C');
document.getElementById("comment").innerHTML="Avoid these guys.";
tutorialCount++;

Step 9 - Animate the character

Step 9: Animate the character

  • Learn how to get things to move on Canvas using JavaScript


Score: 10



Evaluation & Deliverables:

Well, the original plan was to learn how to get things to move using JavaScript, but I actually used JQuery (which is pretty much JavaScript, right?). I am glad I did! Once I learned how to use the animate function, it was pretty manageable to get the character movements set. I turned to my brother-in-law for help on this one. He's a BYU grad in computer science and works as a programmer for a company in Provo. He walked me through the basics of JQuery, specifically on the animate function, adding and removing classes from CSS using JQuery, fade in and fade out, and getting functions to occur in a certain order. We built two character movements together and then I completed the rest on my own.

Anyways, the animations are up and running! They work great on my computer. I noticed when I run the game online that the first few animations are kind of choppy, but then it looks smooth. Here's a link to the game: https://googledrive.com/host/0Bwuo-xxRHyjmOXZSZHA4YmVRSE0/punctuation_project/game.html

Here's some of the scripting to get the character to move. This particular script tells the hero to collect his stolen chips.

function collectCorrect(callback) {
$('#hero').addClass('walking');
$('#hero').animate({
left: 920
}, 1010, 'linear', function(){
$('#hero').removeClass();
$('#hero').addClass('up walking');
$('#hero').animate({
top: 280
}, 700, 'linear', function(){
$('#hero').removeClass('walking');
$('#hero').animate({
top: 280
}, 300, 'linear', function(){
$('#items3').hide();
$('#items2').show();
$('#items1').hide();
$('#itemsOff').hide();
$('#hero').removeClass();
$('#hero').addClass('right walking');
$('#hero').animate({
left: 965
}, 400, 'linear', function(){
$('#hero').removeClass('right walking');
$('#hero').addClass('up');
$('#hero').animate({
top: 280
}, 300, 'linear', function(){
$('#items3').hide();
$('#items2').hide();
$('#items1').show();
$('#itemsOff').hide();
$('#hero').removeClass();
$('#hero').addClass('right walking');
$('#hero').animate({
left: 1010
}, 400, 'linear', function(){
$('#hero').removeClass('right walking');
$('#hero').addClass('up');
$('#hero').animate({
top: 280
}, 300, 'linear', function(){
$('#items3').hide();
$('#items2').hide();
$('#items1').hide();
$('#itemsOff').show();
$('#hero').removeClass();
$('#hero').addClass('down walking');
$('#hero').animate({
top: 370
}, 800, 'linear', function(){
$('#hero').removeClass();
$('#hero').addClass('right walking');
$('#hero').animate({
left: 1020
}, 40, 'linear', callback);
});
});
});
});
});
});
});
});
}

Saturday, March 22, 2014

Step 8 - Create background pieces of game

Step 8: Create background pieces of the game

  • Test buttons against actions that should occur (doing text responses rather than the animations) - learn whatever functions are needed to get this to occur (I’m sure Arrays are involved.
  • Learn about displaying things on Canvas for HTML


Score: 10


Evaluation & Deliverables:

This week, I made all the graphics necessary for the game, and I plugged them into the functions I made previously. Everything is in the right place and working as it should. Sometimes there is a lag in uploading the images, so you see parts popping up at random times as the page loads. I'm wondering if I did a JQuery fade in and fade out if that would cover up the graphics rendering lag? Or is there a function I can do that doesn't display any of the graphics until all the parts are ready?

Anyways, I abandoned the HTML Canvas approach to displaying the game. What I have now with HTML, CSS, and JavaScript seems to be working out alright.

I have several layers of graphics. This allows for the hero to move behind some pieces but in front of others. For example, there is a door that the hero sometimes has to go through. I wanted it to look like he was passing through the door, with some of the graphics in front and some behind. I tested it out by moving the hero around the screen and it seems to work well. Anyways, I have a list of all the images needed for the game in HTML (but I set them to a blank, transparent page; Javascript will change the blank pieces to other images as needed). In CSS, I have each image set to taking an absolute position so that they can be stacked on top of each other. I also assigned them z-scores so I can specify what should be above the hero and what should be below.

Next week I'll be working on getting the animations to come together. Just about done!

Saturday, March 15, 2014

Step 7 - Create a randomizing function to shuffle content in game buttons

Step 7: Create a randomizing function to shuffle content in game buttons

  • Learn about randomizing functions


Score: 10


Evaluation & Deliverables:

This week I searched all over on how to randomize numbers. Codecademy describes the basic Math.floor/Math.random tool. I tried several, but ended up really liking one I found in a Google search, but now I can't find where I got it from. And I can't remember if I combined two approaches, or what. I will do better about this in the future. Anyways, here's the function:

Array.prototype.randomize = function() { var i = this.length, j, temp; while ( --i ) { j = Math.floor( Math.random() * (i - 1) ); temp = this[i]; this[i] = this[j]; this[j] = temp; } }

The idea behind this function is that you can take any array and add .randomize to it to get it to use random numbers. I like this because you do not have to make a new function for each array. 

I have a lot of things in the game that need to be randomized. The main buttons display five different types of punctuation marks used in a sentence. I want each type to show, but I don't want it to always be in the same place every time. So I created an array that included each punctuation mark type and randomized it so that it was displayed in a different order for each new segment of the game. I also didn't want the same sentences to be used, so I created arrays of sentence options using each punctuation mark that could then be randomized. Finally, there are 5 different hallway options that make up the segments of the game. I needed to randomize which order those hallway options appeared in the game so the experience wasn't the same every time you played the game. Having the randomize function made it easy to do all these. Usually I just used an array of numbers, one for each option that the array represented. Then I made if statements to get the game to do different things based on the number produced from the randomizing function.

Here's an example:

var randomizeGameScreen = [1,2,3,4,5];

function renderGameScreen() {
randomizeGameScreen.randomize();
if (randomizeGameScreen[0] === 1) {
document.getElementById("feedback1").innerHTML="Collect Items";
addScorePossible();
document.getElementById("gameScreen").src="hallPractice.jpg";
} else if (randomizeGameScreen[0] === 2) {
document.getElementById("feedback1").innerHTML="Pause";
document.getElementById("gameScreen").src="hallPractice1.jpg";
} else if (randomizeGameScreen[0] === 3) {
document.getElementById("feedback1").innerHTML="Go Through Door";
document.getElementById("gameScreen").src="hallPractice.jpg";
} else if (randomizeGameScreen[0] === 4) {
document.getElementById("feedback1").innerHTML="Door and Collect";
document.getElementById("gameScreen").src="hallPractice1.jpg";
addScorePossible();
} else if (randomizeGameScreen[0] === 5) {
document.getElementById("feedback1").innerHTML="Turn Left";
document.getElementById("gameScreen").src="hallPractice.jpg";
}
}

Anyways, it is working out. I've also fiddled around with backgrounds and characters to see if the randomizing and if statements worked with the graphics, and it seems to be working well (you can see the graphic testing in the example above where a different background image is being displayed. I'll be inserting the real graphics for next week. I think it should be pretty easy to plug in.

Tuesday, March 11, 2014

Peer Critique

This week we are reviewing a peer's project and giving feedback. We are to discuss usability, purpose, flow, function, aesthetic and other relevant elements.

Here's a link to my website: https://googledrive.com/host/0Bwuo-xxRHyjmOXZSZHA4YmVRSE0/punctuation_project/web_resource_mainpage.html

Wednesday, March 5, 2014

Step 6 - Make game interface

Step 6: Make Game Interface

  • Finish JavaScript lessons on Codecademy


Score: 10


Evaluation & Deliverables:

I updated my learning contract for the rest of the semester to better match what I have left to do. Here's a link to the updated file: Learning Contract. This week I finished the lessons on Codecademy. I wanted to get through them to better understand what I will still need to learn beyond Codecademy. I'm glad I finished the lessons there. While some of the lessons are not very clear, some are, and the overall idea of how JavaScript works is worth having.

I made the game interface using HTML and CSS. I realize I need to do better to comment on what I am doing in my files so others can follow what I am doing. I am trying to do that better, but mostly it is showing up in my JavaScript. I also realized that the naming I used for IDs or Classes no longer make sense to what the product is now. Sometimes I took the CSS I wrote for a specific element and ended up reusing it for other elements. I need to go and clean things up at some point so that my coding and programming make sense to others. Anyways, the interface for the game is up and running and I think it will work great.

Wednesday, February 26, 2014

Step 5: Create content for assessments

Step 5: Create content for assessments

  • Control Flow from Codecademy


Score: 10


Evaluation & Deliverables:

This week I learned about switch statements from Codecademy. I think I see how it applies to making a game. I could see there being multiple buttons, and the switch statement identifies what to do when one of those buttons is pressed.

For the deliverables, I made the assessment for my website. The assessment captures the score of all the items into a cookie, saves it, and uploads it on a results page. There is a pre assessment and post assessment. On the post assessment result page, the results of the pre assessment are included alongside the post assessment scores so that the user can see how the two tests differ. The cookie is set to last for 30 days from when it is made...which makes me think that I should have an easy way for a user to come back to the website and see the results without having to go through the assessment (which would then create new cookies and delete the old ones). I'll add that to the list of things to do. It was great to get this to work. Figuring out the JavaScript syntax for making and reading cookies was an adventure.

Here's the code for a pre assessment page that makes a cookie, followed by a results page that reads the cookie (or a link to see the real thing in action: https://googledrive.com/host/0Bwuo-xxRHyjmOXZSZHA4YmVRSE0/punctuation_project/pre_assessment.html)--

Preassessment question page:

<div id="right">
<br>
<h1>Colons</h1>
<div id="quiz">
<p>1. What can you use colons for? Check all that apply.</p>
<div class="tryItOutCheckBox">
<input id="colonQuestionOneA" type="checkbox"> A. Indicate 'more to come' before the next idea.<br><br>
<input id="colonQuestionOneB" type="checkbox"> B. Separate background information from the main idea of a sentence.<br><br>
<input id="colonQuestionOneC" type="checkbox"> C. Separate items in a list.<br><br>
<input id="colonQuestionOneD" type="checkbox"> D. Introduce a list.<br><br>
</div>
<p>2. Check the boxes next to the sentences that properly use the colon:</p>
<div class="tryItOutCheckBox">
<input id="colonQuestionTwoA" type="checkbox"> A. Please take out<span style="font-family:Arial">:</span> your textbook, a calculator, and a pencil.<br><br>
<input id="colonQuestionTwoB" type="checkbox"> B. There is only one thing to do<span style="font-family:Arial">:</span> jump in a lake.<br><br>
<input id="colonQuestionTwoC" type="checkbox"> C. Here is what we'll do today<span style="font-family:Arial">:</span> swim, hike, and roast mallows.<br><br>
</div>
<p>3. Add colons where they are needed:</p>
<div class="tryItOutCheckBox">
<p> A. I would like <input id="colonQuestionThreeAOne" type="text" class="fieldBox"> a hamburger <input id="colonQuestionThreeATwo" type="text" class="fieldBox"> and fries.</p>
<p> B. Here's what we'll do <input id="colonQuestionThreeBOne" type="text" class="fieldBox"> make like trees <input id="colonQuestionThreeBTwo" type="text" class="fieldBox"> and leave.</p>
<p> C. Please write the following <input id="colonQuestionThreeCOne" type="text" class="fieldBox"> your first name, last name, and birthdate.</p>
</div>
<script>
var QuestionOneAScore = 0;
var QuestionOneBScore = 0;
var QuestionOneCScore = 0;
var QuestionOneDScore = 0;
var QuestionTwoAScore = 0;
var QuestionTwoBScore = 0;
var QuestionTwoCScore = 0;
var QuestionThreeAOneScore = 0;
var QuestionThreeATwoScore = 0;
var QuestionThreeBOneScore = 0;
var QuestionThreeBTwoScore = 0;
var QuestionThreeCOneScore = 0;
var totalScore = 0;

function addScoreFunction() {
totalScore = (QuestionOneAScore + QuestionOneBScore + QuestionOneCScore + QuestionOneDScore + QuestionTwoAScore + QuestionTwoBScore + QuestionTwoCScore + QuestionThreeAOneScore + QuestionThreeATwoScore + QuestionThreeBOneScore + QuestionThreeBTwoScore + QuestionThreeCOneScore);
setCookie();
}

function setCookie() {
            var date = new Date();
            date.setTime(date.getTime()+(30*24*60*60*1000));
            var expires = "; expires="+date.toGMTString();
document.cookie = "colonScore=" + totalScore + ";" + expires + "path=/";
}

function submitAnswerFunction() {
var QuestionOneA = document.getElementById("colonQuestionOneA").checked;
var QuestionOneB = document.getElementById("colonQuestionOneB").checked;
var QuestionOneC = document.getElementById("colonQuestionOneC").checked;
var QuestionOneD = document.getElementById("colonQuestionOneD").checked;
var QuestionTwoA = document.getElementById("colonQuestionTwoA").checked;
var QuestionTwoB = document.getElementById("colonQuestionTwoB").checked;
var QuestionTwoC = document.getElementById("colonQuestionTwoC").checked;
var QuestionThreeAOne = document.getElementById("colonQuestionThreeAOne").value;
var QuestionThreeATwo = document.getElementById("colonQuestionThreeATwo").value;
var QuestionThreeBOne = document.getElementById("colonQuestionThreeBOne").value;
var QuestionThreeBTwo = document.getElementById("colonQuestionThreeBTwo").value;
var QuestionThreeCOne = document.getElementById("colonQuestionThreeCOne").value;

if (QuestionOneA == true) {
QuestionOneAScore = 1;
} else {
QuestionOneAScore = 0;
}
if (QuestionOneB == false) {
QuestionOneBScore = 1;
} else {
QuestionOneBScore = 0;
}
if (QuestionOneC == false) {
QuestionOneCScore = 1;
} else {
QuestionOneCScore = 0;
}
if (QuestionOneD == true) {
QuestionOneDScore = 1;
} else {
QuestionOneDScore = 0;
}
if (QuestionTwoA == false) {
QuestionTwoAScore = 1;
} else {
QuestionTwoAScore = 0;
}
if (QuestionTwoB == true) {
QuestionTwoBScore = 1;
} else {
QuestionTwoBScore = 0;
}
if (QuestionTwoC == true) {
QuestionTwoCScore = 1;
} else {
QuestionTwoCScore = 0;
}
if (QuestionThreeAOne === "") {
QuestionThreeAOneScore = 1;
} else {
QuestionThreeAOneScore = 0;
}
if (QuestionThreeATwo === "") {
QuestionThreeATwoScore = 1;
} else {
QuestionThreeATwoScore = 0;
}
if (QuestionThreeBOne === ":") {
QuestionThreeBOneScore = 1;
} else {
QuestionThreeBOneScore = 0;
}
if (QuestionThreeBTwo === "") {
QuestionThreeBTwoScore = 1;
} else {
QuestionThreeBTwoScore = 0;
}
if (QuestionThreeCOne === ":") {
QuestionThreeCOneScore = 1;
} else {
QuestionThreeCOneScore = 0;
}
addScoreFunction();
}
</script>
<br>
<p class="right" onclick="submitAnswerFunction()"><a href="semicolonPreQuiz.html">Next-></p>
</div>
</div>



Preassessment Results Page:

<head>
<link type="text/css" rel="stylesheet" href="stylesheet.css"/>
<title>The Punctuation Project</title>
<script>
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
  var c = ca[i].trim();
  if (c.indexOf(name)==0) return c.substring(name.length,c.length);
  }
return "";
}

function checkCommaScore() {
var commaPreScore=getCookie("commaScore");
if (commaPreScore >= 12) {
document.getElementById("feedback1").innerHTML=commaPreScore +"/14 - Excellent! You know your commas!";
} else if (commaPreScore >= 9 && commaPreScore <= 11) {
document.getElementById("feedback1").innerHTML=commaPreScore
+ "/14 - You know quite a bit about commas. Reviewing commas in the lessons could still be helpful";
} else {
document.getElementById("feedback1").innerHTML=commaPreScore + "/14 - It would be helpful for you to brush up on commas";
}
checkColonScore();
}
function checkColonScore() {
var colonPreScore=getCookie("colonScore");
if (colonPreScore >= 10) {
document.getElementById("feedback2").innerHTML=colonPreScore +"/12 - Excellent! You know your colons!";
} else if (colonPreScore >= 7 && colonPreScore <= 9) {
document.getElementById("feedback2").innerHTML=colonPreScore
+ "/12 - You know quite a bit about colons. Reviewing colons in the lessons could still be helpful";
} else {
document.getElementById("feedback2").innerHTML=colonPreScore + "/12 - It would be helpful for you to brush up on colons";
}
checkSemicolonScore();
}
function checkSemicolonScore() {
var semicolonPreScore=getCookie("semicolonScore")
if (semicolonPreScore >= 10) {
document.getElementById("feedback3").innerHTML=semicolonPreScore +"/14 - Excellent! You know your semicolons!";
} else if (semicolonPreScore >= 8 && semicolonPreScore <= 9) {
document.getElementById("feedback3").innerHTML=semicolonPreScore
+ "/14 - You know quite a bit about semicolons. Reviewing semicolons in the lessons could still be helpful";
} else {
document.getElementById("feedback3").innerHTML=semicolonPreScore + "/14 - It would be helpful for you to brush up on semicolons";
}
}
</script>
</head>
<body onload="checkCommaScore()">
<div id="header">
<h1>The Punctuation Project</h1>
</div>
<div id="left">
<div id="navbar">
<ul>
<a href="web_resource_mainpage.html"><li>Home</li></a>
<a href="pre_assessment.html"><li class="current">See What You Know</li></a>
<a href="lessons.html"><li>Learn the Marks</li></a>
<a href="game.html"><li>Test Your Skills</li></a>
<a href="post_assessment.html"><li>See if You've Got It</li></a>
</ul>
</div>
</div>
<div id="right">
<br>
<h1>Here are the results of your pretest:</h1>
<div class="tryItOutCheckBox">
<h2>Commas</h2>
<p id="feedback1">...</p>
<h2>Colons</h2>
<p id="feedback2">...</p>
<h2>Semicolons</h2>
<p id="feedback3">...</p>
</div>