Script
Script
onload = function () {
var alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
't', 'u', 'v', 'w', 'x', 'y', 'z'];
// Get elements
var showLives = document.getElementById("mylives");
var showCatagory = document.getElementById("scatagory");
var getHint = document.getElementById("hint");
var showClue = document.getElementById("clue");
// create alphabet ul
var buttons = function () {
myButtons = document.getElementById('buttons');
letters = document.createElement('ul');
// Select Catagory
var selectCat = function () {
if (chosenCategory === categories[0]) {
catagoryName.innerHTML = "The Chosen Category Is Premier League Football
Teams";
} else if (chosenCategory === categories[1]) {
catagoryName.innerHTML = "The Chosen Category Is Films";
} else if (chosenCategory === categories[2]) {
catagoryName.innerHTML = "The Chosen Category Is Cities";
}
}
// Create geusses ul
result = function () {
wordHolder = document.getElementById('hold');
correct = document.createElement('ul');
geusses.push(guess);
wordHolder.appendChild(correct);
correct.appendChild(guess);
}
}
// Show lives
comments = function () {
showLives.innerHTML = "You have " + lives + " lives";
if (lives < 1) {
showLives.innerHTML = "Game Over";
}
for (var i = 0; i < geusses.length; i++) {
if (counter + space === geusses.length) {
showLives.innerHTML = "You Win!";
}
}
}
// Animate man
var animate = function () {
var drawMe = lives ;
drawArray[drawMe]();
}
// Hangman
canvas = function(){
myStickman = document.getElementById("stickman");
context = myStickman.getContext('2d');
context.beginPath();
context.strokeStyle = "#fff";
context.lineWidth = 2;
};
head = function(){
myStickman = document.getElementById("stickman");
context = myStickman.getContext('2d');
context.beginPath();
context.arc(60, 25, 10, 0, Math.PI*2, true);
context.stroke();
}
/*
draw = function($pathFromx, $pathFromy, $pathTox, $pathToy) {
context.moveTo($pathFromx, $pathFromy);
context.lineTo($pathTox, $pathToy);
context.stroke();
}
frame1 = function() {
draw (0, 150, 150, 150);
};
frame2 = function() {
draw (10, 0, 10, 600);
};
frame3 = function() {
draw (0, 5, 70, 5);
};
frame4 = function() {
draw (60, 5, 60, 15);
};
torso = function() {
draw (60, 36, 60, 70);
};
rightArm = function() {
draw (60, 46, 100, 50);
};
leftArm = function() {
draw (60, 46, 20, 50);
};
rightLeg = function() {
draw (60, 70, 100, 100);
};
leftLeg = function() {
draw (60, 70, 20, 100);
};
// OnClick Function
check = function () {
list.onclick = function () {
var geuss = (this.innerHTML);
this.setAttribute("class", "active");
this.onclick = null;
for (var i = 0; i < word.length; i++) {
if (word[i] === geuss) {
geusses[i].innerHTML = geuss;
counter += 1;
}
}
var j = (word.indexOf(geuss));
if (j === -1) {
lives -= 1;
comments();
animate();
} else {
comments();
}
}
}
// Play
play = function () {
categories = [
["waterlily", "islam", "green", "milk", "twenty-five", "dhaka", "seven"],
/*
["alien", "dirty-harry", "gladiator", "finding-nemo", "jaws"],
["manchester", "milan", "madrid", "amsterdam", "prague"] */
];
geusses = [ ];
lives = 10;
counter = 0;
space = 0;
result();
comments();
selectCat();
canvas();
}
play();
// Hint
hint.onclick = function() {
hints = [
["National flower of Bangladesh", "Main religion in Bangladesh", "color
starts with the letter G", "Drink that comes from a cow", "What is 5 x 5", "Capital
of Bangladesh", "How many day in a week"],
/*
["Science-Fiction horror film", "1971 American action film",
"Historical drama", "Anamated Fish", "Giant great white shark"],
["Northern city in the UK", "Home of AC and Inter", "Spanish capital",
"Netherlands capital", "Czech Republic capital"] */
];
// Reset
document.getElementById('reset').onclick = function() {
correct.parentNode.removeChild(correct);
letters.parentNode.removeChild(letters);
showClue.innerHTML = "";
context.clearRect(0, 0, 400, 400);
play();
}
}