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>




Wednesday, February 19, 2014

Learning Project Step 4 Report: Add style to learning content on website

Step 3: Add learning content as HTML to website

  • For and While Loops


Score: 10


Evaluation & Deliverables:

This week I learned about if/else statements and for/while/do loops in JavaScript. I also did checked out how to get JavaScript to do things with your HTML. As part of my application of what I learned, I completed the practice questions in the lesson portion of my website. The practice questions either have users type the correct letter answer or check the appropriate box to answer a question. The questions are built into the lessons to let users try out what they are learning.

Things have been successful so far. I think I am making good progress. I think I might see if I can change the learning goals over the next few weeks and what my deliverables will be. I noticed that my first learning contract isn't spelling out what learning material will be most applicable to my project. I think I could use some help in identifying what I should specifically learn about JavaScript to get my game up and running.

Anyways, here is an example of one of my practice questions using HTML field boxes and JavaScript:

<div id="tryItOut">
<h3>Try it out:</h3>
<p><em>Let's just see if you can tell what the commas in each of these sentences are doing. Match the sentence with the right description of how the comma is used:</em></p>
<div class="tryItOutCheckBox">
<input class="fieldBox" id="commaQuestionOne" type="text"> 1. Add the following ingredients together: strawberries, oreos, and vanilla ice cream.<br><br>
<input class="fieldBox" id="commaQuestionTwo" type="text"> 2. We'll go to that class, but I don't think it will make a difference.<br><br>
<input class="fieldBox" id="commaQuestionThree" type="text"> 3. After the dance, we'll head to the movies.<br><br>
<h3>Answers</h3>
<p>A. bring two ideas together into the same sentence</p>
<p>B. separate background info from the main idea of the sentence</p>
<p>C. make lists</p>
<p id="submitButton" onclick="checkAnswerFunction()">Submit</p>
</div>
<script>
function checkAnswerFunction() {
var questionOne = document.getElementById("commaQuestionOne").value;
var questionTwo = document.getElementById("commaQuestionTwo").value;
var questionThree = document.getElementById("commaQuestionThree").value;
var answerARight = "Great! We have two ideas that are being brought together into the same sentence!"
var answerAWrong = "Almost. There aren't two ideas being brought together here. You should be able to separate the two ideas and make them into their own sentences that would make sense to someone if you read them out loud."
var answerBRight = "Nice work! We have some background info that is helping explain the main idea."
var answerBWrong = "Close. Background info can be removed from the sentence, and the sentence will still be able to make sense on its own."
var answerCRight = "Way to go! We have a list of items here."
var answerCWrong = "Not quite. A sentence with a list presents something that you could check off when each thing was done or obtained. "
if (questionOne === "c" || questionOne === "C") {
document.getElementById("feedback1").innerHTML="1. "+answerCRight;
} else if (questionOne === "b" || questionOne === "B") {
document.getElementById("feedback1").innerHTML="1. "+answerBWrong;
} else if (questionOne === "a" || questionOne === "A") {
document.getElementById("feedback1").innerHTML="1. "+answerAWrong;
} else {
document.getElementById("feedback1").innerHTML="1. Not a valid answer."
}
if (questionTwo === "c" || questionTwo === "C") {
document.getElementById("feedback2").innerHTML="2. "+answerCWrong;
} else if (questionTwo === "b" || questionTwo === "B") {
document.getElementById("feedback2").innerHTML="2. "+answerBWrong;
} else if (questionTwo === "a" || questionTwo === "A") {
document.getElementById("feedback2").innerHTML="2. "+answerARight;
} else {
document.getElementById("feedback2").innerHTML="2. Not a valid answer."
}
if (questionThree === "c" || questionThree === "C") {
document.getElementById("feedback3").innerHTML="3. "+answerCWrong;
} else if (questionThree === "b" || questionThree === "B") {
document.getElementById("feedback3").innerHTML="3. "+answerBRight;
} else if (questionThree === "a" || questionThree === "A") {
document.getElementById("feedback3").innerHTML="3. "+answerAWrong;
} else {
document.getElementById("feedback3").innerHTML="3. Not a valid answer."
}
}
</script>
<div id="feedback">
<h3>Feedback</h3>
<p id="feedback1"></p>
<p id="feedback2"></p>
<p id="feedback3"></p>
</div>
</div>

Thursday, February 13, 2014

Learning Project Step 3 Report: Add learning content as HTML to website

Step 3: Add learning content as HTML to website

  • Introduction to JavaScript


Score: 8



Evaluation & Deliverables:

So this is one of those weeks where I wondered what I was thinking in making my learning contract. I'm sure I'll have more of those weeks. Anyways, I did make all the lesson content for the website, and I did make the HTML tags in the content, but I did not finish getting all the content to the website. Here's a link to the content as a Google Doc: https://docs.google.com/document/d/1gf52E9mVqLaHRre7rFzXgKK6tRs4a05chcjUpzbBUYM/edit?usp=sharing

I did get a lot of the pages to the website. I'm pretty close to getting it done. Getting the content written up was the main goal of this week, and I am satisfied with the result.

I spent a lot of time trying to figure out how to do drop-down menu's for my nav bars. I've found some websites explaining how to do it, but I never could get it to fully work on my website. I gave up for now as it wasn't essential.

Many of my lesson pages have an opportunity for learners to practice what they are learning with a practice question. I still need to learn JavaScript to get them running. I'll be excited when they are in. I'm puzzled and looking forward to seeing how I can display content on my website using JavaScript (like feedback comments based on what button users pressed).

-------------------------------------

As part of this week's lesson, I was to make a game of rock, paper, scissors, where I could practice using functions. Here's the result:

var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
computerChoice = "rock";
} else if(computerChoice <= 0.67) {
computerChoice = "paper";
} else {
computerChoice = "scissors";
}

console.log("Your choice:" + " " + userChoice);
console.log("Computer choice:" + " " + computerChoice);

var compare = function (choice1, choice2) {
    if (choice1 === choice2) {
        return ("The result is a tie!");
    } else if (choice1 === "rock") {
        if (choice2 === "scissors") {
            return ("rock wins");
        } else {
            return ("paper wins");
        }
    } else if (choice1 === "paper") {
        if (choice2 === "scissors") {
            return ("scissors wins");
        } else {
            return ("paper wins");
        }
    } else {
        if (choice2 === "paper") {
            return ("scissors wins");
        } else {
            return ("rock wins");
        }
    }
}

compare (userChoice, computerChoice);

Friday, February 7, 2014

Learning Project Step 2 Report: Create an outline for the logic of the game

Step 2: Create an outline for the logic of the game

  • Introduction to JavaScript


Score: 10



Evaluation & Deliverables:

JavaScript is way different to me than HTML or CSS. The latter two make a lot of sense to me. I have a sense of what goes into a webpage and to know what kinds of things to look for if I have a question. With JavaScript, I have little clue what it can do. I'm sure Codecademy will help.

This week's goal was to make an outline for the game portion of my instructional tool. The basic idea of the game is that the player is part of an operation to recover stolen artifacts from a major art thief. The player has located all the artifacts in the house and is given code signals to a partner to help the partner navigate through the thief's mansion and retrieve the stolen goods. The code signals are made up of different uses of punctuation marks the student has learned. In the game, the player will see a top-down view of the mansion hallways. A flashing dot will represent their partner. Smaller flashing dots represent artifacts to collect. The player will be shown a small portion of the building at a time - enough for the player to have to make a decision which direction to send the partner. Directions will include turning down a different hallway (;), going through a door (:), leaving a building to go to a new one (.), pausing to avoid a booby-trap(,), or collecting a certain number of items in the hallway(,,,). Direction options are presented as sentences using various punctuation. The player chooses the appropriate sentence to deliver to the partner. The partner then follows the code directions given. Thugs and guard dogs are on the alert in the various hallways (will also show up as a certain signal in the game). The bad guys will help make it so there is only one right way to go. If the player sends the partner in the wrong direction, the partner has an encounter with the bad guys. After three encounters with bad guys, it is game over. Points are awarded for the number of artifacts collected.

It seems reasonable that the game could be different every time someone played. If presented hallway types were put in categories, and it was programmed which types of categories could follow another, then the game could possibly randomly assign hallway sequences. Sentence options could also be assigned to certain hallway categories so those could be randomly assigned in a smart way.

Here are the directions (sentence options):

  • (";") Turn left (or right - only one turn option will be available) into a new hallway
  • (":") Continue through door
  • ("." - sentence with no punctuation but a period) Exit building and head to the next one
  • (",") Pause briefly in hallway to deactivate booby-trap
  • (", , ," - sentence with a list) Gather the number of items in the hallway as indicated by the length of the list
  • (": , , ," - colon followed by a list) Go through the door and gather the number of items in the hallway as indicated by the length of the list. 
I would make a bank of sentence options that the system could choose to present based on room type (would present four options to the player).


Here are the hallway options and rules:


  • Wrong ways will be indicated to the player by an icon representing a bad guy. 
  • A continuing hallway (1) is one coming from the left side of the screen and heading straight through the right side of the screen.
  • A joined hallway is one that is starting from above or below, but turns to follow the normal course from left to right. An "above" joined hallway (2) is one that starts at the top of the screen, and "below" (3) vice versa.
  • A beginning hallway (4) is one starting from a building entrance. Entrance is on the left, hallway heads right.
  • An exit (5) is a hallway that ends at a door that leads out of the building.
  • If a player chooses the wrong way, they must try the hallway again (until three errors have been made, in which case the game is over).
  • A player in a hallway with items could be presented with a comma list that would tell the partner to collect fewer items than present in the hallway, in which case, the player would earn less points).
  • I have indicated the types of hallway beginnings and endings with numbers in parentheses (as indicated in the rules above). 
  • An ending 1 must follow up with a starting 1
  • An ending 2 must follow up with a starting 2
  • An ending 3 must follow up with a starting 3
  • An ending 5 must follow up with a starting 4



  • Start: From beginning hallway, head through door to continuing hallway (1) (wrong way: right turn).
  • The following would be randomized to change up gameplay:
    • (1) From continuing hallway, turn left (3) (wrong way: door leading to a continuing hallway).
    • (1) From continuing hallway, turn right (2) (wrong way: door leading to a continuing hallway).
    • (1) From continuing hallway, head through door leading to continuing hallway (1) (wrong way: turn right).
    • (1) From continuing hallway, exit building (5) (wrong way: turn left).
    • (1) From continuing hallway, exit building (5) (wrong way: turn right).
    • (1) From continuing hallway, pause to deactivate booby trap, then proceed through hallway (1) (wrong way is heading into the booby trap).
    • (1) From continuing hallway, collect three items and proceed through hallway (1) (wrong way: left turn).
    • (1) From continuing hallway, collect two items and proceed through hallway (1) (wrong way: left turn).
    • (1) From continuing hallway, collect four items and proceed through hallway (1) (wrong way: left turn).
    • (1) From continuing hallway, collect three items and proceed through hallway (1) (wrong way: right turn).
    • (1) From continuing hallway, collect two items and proceed through hallway (1) (wrong way: right turn).
    • (1) From continuing hallway, collect four items and proceed through hallway (1) (wrong way: right turn).
    • (1) From continuing hallway, proceed through door and collect three items (1) (wrong way: left turn).
    • (1) From continuing hallway, proceed through door and collect three items (1) (wrong way: right turn).
    • (4) From beginning hallway, proceed through door and collect three items (1) (wrong way: right turn).
    • (4) From beginning hallway, collect three items and proceed through hallway (1) (wrong way: right turn).
    • (4) From beginning hallway, pause to deactivate booby trap, then proceed through hallway (1) (wrong way is heading into the booby trap).
    • (2) From above joined hallway, collect three items and proceed through hallway (1) (wrong way: right turn).
    • (2) From above joined hallway, proceed through door and collect three items (1) (wrong way: left turn).
    • (2) From above joined hallway, exit building (5) (wrong way: left turn).
    • (3) From below joined hallway, pause to deactivate booby trap, then proceed through hallway (1) (wrong way is heading into the booby trap).
    • (3) From below joined hallway, exit building (5) (wrong way: turn right).
    • (3) From below joined hallway, collect three items and proceed through hallway (1) (wrong way: right turn).
  • End: (1) From continuing hallway, exit building (wrong way: left turn).
The system would use the same start and end, but the middle hallway options would be randomized. The system would select 10 hallway options in the middle (wouldn't follow all the possible options).

I think to make this all happen, I will create short video clips for each scenario listed above. I don't think the video clips would take too long. I would need a static hallway setup, and then alternating images of flashing dots for the partner, items, and bad guys. I'd then make images of the partner moving in the direction given by the player. I'd string all those images together in iMovie to make the clips. Then, the JavaScript could execute the clip that corresponds with a hallway option and player direction given in the game.

Here's an example movie: http://youtu.be/vVaADgpfsno

_________________________________________________________

As part of this week's JavaScript lesson on Codecademy, I was supposed to make a basic choose your own adventure game. Seemed pretty simple. Here's the result:

confirm("Are you ready to play?");

var age;

age = prompt("What's your age?");

if (age < 18) {
    console.log("You are allowed to play, but we take no responsibility for the results of your gameplay");
} else {
    console.log("Then let's play!");
}

console.log("Snow White and Batman were hanging out at the bus stop, waiting to go to the shops. There was a sale on and both needed some new threads. You've never really liked Batman. You walk up to him.");
console.log("Batman glares at you.");
var userAnswer

userAnswer = prompt("Batman: Are you feeling lucky, punk?");

if (userAnswer === "yes") {
    console.log("Batman hits you very hard. It's Batman and you're you! Of course Batman wins!");
} else {
    console.log("You did not say yes to feeling lucky. Good choice! You are a winner in the game of not getting beaten up by Batman.");
}

var feedback

feedback = prompt("Rate this game on a scale of 1 to 10");

if (feedback > 8) {
    console.log("This is just the beginning of my game empire. Stay tuned for more!");
} else {
    console.log("I slaved away at this game and you gave me that score?! The nerve! Just you wait!");
}

Saturday, February 1, 2014

Learning Project Step 1 Report: Build the basic html shell of the web resource

Step 1: Build the basic html shell of the web resource

  • Introduction to CSS
  • CSS Classes & IDs
  • CSS Element Positioning


Score: 10


Evaluation:

I'm new to HTML and CSS. We've been working on HTML and CSS in class, but I wanted to round off what I have been learning by going through the HTML/CSS course on Codecademy. I had gone through most of the lessons before I made the learning contract. I decided to use Step 1 to finish the CSS lessons. My biggest goal this week was to learn how to position different parts of my webpage. Codecademy was very helpful in that regard. 

My deliverable for this week was to create the "shell" for by web-based game that I will be building this semester. I also decided to round out my PLE as well using what I've learned about HTML and CSS. After I finished the lesson, I went to work on building my PLE.

It was exciting to make my first website. Codecademy gave me the basics. W3Schools helped me personalize things and give them flair. I'm using Google Drive to host my website. I have the Google Drive extension on my computer, which saves a folder to my Finder, syncs files so they can be accessed offline, and automatically update to the web server when I make changes to the files. The url isn't pretty, but it gets the job done. My most favorite part was learning how to download a unique font and have it display on my website for me and all my users (hopefully that is working!). I also learned that you can create different hover functions for things other than links. I made a hover function for my navigation buttons.

I created a basic HTML structure with sections for my website (header, left, right, and footer), using div id tags. I created a navigation bar in my left div, and gave style to its functions. I was pleased with how it turned out.

One thing that has been a frustration is that one of my pages (the first page in my PLE) displays the header differently than the others. I've combed through the page (https://googledrive.com/host/0Bwuo-xxRHyjmOXZSZHA4YmVRSE0/web_resource_mainpage.html) and the accompanying css file to see what would be causing the problem. The CSS works for all my other pages, and is no different for my first page. Other than that, I believe everything is working as planned.

Here's the basic structure for my PLE's main page, followed by the CSS scripting:

HTML

<!DOCTYPE html>
<html>
<head>
<link type="text/css" rel="stylesheet" href="main_stylesheet.css"/>
<title>Instructional Tools designed by Curtis Henrie</title>
</head>
<body>
<div id="header">
<h1>Instructional Tools designed by Curtis Henrie</h1>
</div>
<div id="left">
<div id="navbar">
<ul>
<a href="index.html"><li class="current">Home</li></a>
<a href="punctuation_project.html"><li>Punctuation Project</li></a>
<a href="owl_project.html"><li>Owl Project</li></a>
<a href="esl_tutor_training_program.html"><li>ESL Tutor Training Program</li></a>
<a href="https://sites.google.com/site/curtisrhenrie/home"><li>Curtis R. Henrie Website</li></a>
</ul>
</div>
</div>
<div id="right">
</div>
<div id="footer">
</div>
</body>
</html>



CSS

@font-face {
font-family: Raleway;
src: url(https://googledrive.com/host/0Bwuo-xxRHyjmOXZSZHA4YmVRSE0/Raleway-Thin.otf);
}

body {
background-color: black;
}

#header {
position: relative;
}

#header h1 {
font-family: Raleway; Trebuchet MS, Arial, sans-serif;
color: #FFFFFF;
font-size: 3em;
font-weight: 100;
text-align: left;
padding-left: 3%;
padding-top: 1%;
padding-bottom: 2%;
}

#left {
float: left;
width: 25%;
margin-right: -1%;
}

#navbar {
margin-top: -16px;
}

#navbar li {
padding: 15px;
padding-left: 30px;
font-family: Raleway, Trebuchet MS; Arial, sans-serif;
font-weight: 100;
font-size: 1.3em;
color: #A0A0A0;
background-color: #282828;
list-style-type: none;
}

/*Special formatting for the navbar button that matches the current page*/
#navbar .current {
padding: 15px;
padding-left: 17px;
font-family: Raleway, Trebuchet MS, Arial, sans-serif;
font-weight: 100;
font-size: 1.3em;
background-color: #404040;
list-style-type: none;
color: #ffffff;
}

#navbar li:hover {
background-color: #606060;
color: #ffffff;
}

a:link {
text-decoration: none;
}

a:hover {
text-decoration: none;
}

a:visited {
text-decoration: none;
}

#right {
float: right;
width: 65%;
background-color: #404040;
padding: 3% 5% 3% 5%;
margin-left: -1%;
font-family: Raleway, Arial;
font-size: 1.2em;
color: #D0D0D0;
}

#right h2 {
font-family: Raleway, Arial;
color: #ffffff;
font-weight: bolder;
}

#right a {
color: #D0D0D0;
}

#right a:link {
text-decoration: none;
}

#right a:hover {
text-decoration: none;
color: #ffffff;
}

#right a:visited {
text-decoration: none;
}

#footer {
clear: both;
position: relative;
}