BTOOM!
This commit is contained in:
parent
c3d665c3b3
commit
bc508119d7
1
html/README.md
Normal file
1
html/README.md
Normal file
@ -0,0 +1 @@
|
||||
![Screenshot](https://raw.githubusercontent.com/iiiypuk/hgman/master/html/screen.png)
|
1
html/Vegur/.gitignore
vendored
Normal file
1
html/Vegur/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.otf
|
1
html/Vegur/README.md
Normal file
1
html/Vegur/README.md
Normal file
@ -0,0 +1 @@
|
||||
Download from [it](http://dotcolon.net/font/vegur/).
|
7
html/Vegur/vegur.css
Normal file
7
html/Vegur/vegur.css
Normal file
@ -0,0 +1,7 @@
|
||||
@font-face {
|
||||
font-family: 'Vegur';
|
||||
src: url('Vegur-Regular.otf') format('opentype');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
|
||||
}
|
58
html/game.js
Normal file
58
html/game.js
Normal file
@ -0,0 +1,58 @@
|
||||
var words = ['google', 'speed', 'window', 'horizon'];
|
||||
|
||||
var lives = 6;
|
||||
var gameWord = words[Math.floor(Math.random() * words.length)].toUpperCase();
|
||||
var gameAnswered = new Array(gameWord.length + 1).join('-')
|
||||
|
||||
window.onload = function()
|
||||
{
|
||||
console.log(gameWord)
|
||||
document.getElementById("WORD").innerHTML = gameAnswered;
|
||||
document.getElementById("lives").innerHTML = 'Lives ' + lives;
|
||||
}
|
||||
|
||||
function wrong()
|
||||
{
|
||||
lives -= 1;
|
||||
document.getElementById("lives").innerHTML = 'Lives ' + lives;
|
||||
}
|
||||
|
||||
function offChar(char)
|
||||
{
|
||||
var charButton = document.getElementById(char);
|
||||
charButton.disabled = true;
|
||||
|
||||
if (gameAnswered.split('').indexOf('-') == -1)
|
||||
{
|
||||
alert('You Win');
|
||||
return;
|
||||
}
|
||||
|
||||
if (lives == 0) {
|
||||
alert('You dead');
|
||||
return;
|
||||
}
|
||||
|
||||
var indices = [];
|
||||
var idx = gameWord.split('').indexOf(char)
|
||||
if (idx == -1)
|
||||
{
|
||||
wrong();
|
||||
return;
|
||||
}
|
||||
|
||||
while (idx != -1)
|
||||
{
|
||||
indices.push(idx);
|
||||
idx = gameWord.split('').indexOf(char, idx + 1);
|
||||
}
|
||||
console.log(indices)
|
||||
|
||||
indices.forEach(function(item, indices)
|
||||
{
|
||||
var wordArray = gameAnswered.split('')
|
||||
wordArray[item] = char;
|
||||
gameAnswered = wordArray.join('');
|
||||
document.getElementById("WORD").innerHTML = gameAnswered;
|
||||
})
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
__author__ = 'Alexander Popov'
|
||||
__version__ = '0.1.0'
|
||||
__version__ = '1.0.0'
|
||||
__license__ = 'MIT'
|
||||
|
||||
usQwertyKeyboard = 'abcdefghijklmnopqrstuvwxyz'.upper()
|
||||
@ -10,7 +10,9 @@ def genKeys(alphabet):
|
||||
keys = list()
|
||||
|
||||
for letter in alphabet:
|
||||
keys.append('<button onclick="offChar(\'%s\')">%s</button>' % (letter, letter)) # FIX IT
|
||||
keys.append(
|
||||
'<button id="{l}" onclick="offChar(\'{l}\')">{l}</button>'
|
||||
.format(l=letter))
|
||||
|
||||
return(keys)
|
||||
|
||||
|
@ -9,31 +9,8 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<title>hgman</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.wrap {
|
||||
max-width: 400px;
|
||||
margin: 10px auto;
|
||||
}
|
||||
|
||||
div.word, div.lives {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
div.keyboard {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
div.keyboard button {
|
||||
padding: 8px;
|
||||
border: 1px solid #999;
|
||||
box-sizing: border-box;
|
||||
margin: 2px;
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" type="text/css" href="styles.css">
|
||||
<link rel="stylesheet" type="text/css" href="Vegur/vegur.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@ -47,66 +24,12 @@
|
||||
</div>
|
||||
|
||||
<div class="keyboard">
|
||||
<button onclick="offChar('A')">A</button><button onclick="offChar('B')">B</button><button onclick="offChar('C')">C</button><button onclick="offChar('D')">D</button><button onclick="offChar('E')">E</button><button onclick="offChar('F')">F</button><button onclick="offChar('G')">G</button><button onclick="offChar('H')">H</button><button onclick="offChar('I')">I</button><button onclick="offChar('J')">J</button><button onclick="offChar('K')">K</button><button onclick="offChar('L')">L</button><button onclick="offChar('M')">M</button><button onclick="offChar('N')">N</button><button onclick="offChar('O')">O</button><button onclick="offChar('P')">P</button><button onclick="offChar('Q')">Q</button><button onclick="offChar('R')">R</button><button onclick="offChar('S')">S</button><button onclick="offChar('T')">T</button><button onclick="offChar('U')">U</button><button onclick="offChar('V')">V</button><button onclick="offChar('W')">W</button><button onclick="offChar('X')">X</button><button onclick="offChar('Y')">Y</button><button onclick="offChar('Z')">Z</button>
|
||||
</div>
|
||||
<button id="A" onclick="offChar('A')">A</button><button id="B" onclick="offChar('B')">B</button><button id="C" onclick="offChar('C')">C</button><button id="D" onclick="offChar('D')">D</button><button id="E" onclick="offChar('E')">E</button><button id="F" onclick="offChar('F')">F</button><button id="G" onclick="offChar('G')">G</button><button id="H" onclick="offChar('H')">H</button><button id="I" onclick="offChar('I')">I</button><button id="J" onclick="offChar('J')">J</button><button id="K" onclick="offChar('K')">K</button><button id="L" onclick="offChar('L')">L</button><button id="M" onclick="offChar('M')">M</button><button id="N" onclick="offChar('N')">N</button><button id="O" onclick="offChar('O')">O</button><button id="P" onclick="offChar('P')">P</button><button id="Q" onclick="offChar('Q')">Q</button><button id="R" onclick="offChar('R')">R</button><button id="S" onclick="offChar('S')">S</button><button id="T" onclick="offChar('T')">T</button><button id="U" onclick="offChar('U')">U</button><button id="V" onclick="offChar('V')">V</button><button id="W" onclick="offChar('W')">W</button><button id="X" onclick="offChar('X')">X</button><button id="Y" onclick="offChar('Y')">Y</button><button id="Z" onclick="offChar('Z')">Z</button>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var words = ['wood', 'speed'];
|
||||
<footer>2017 by iiiypuk</footer>
|
||||
</div>
|
||||
|
||||
var lives = 6;
|
||||
var gameWord = words[Math.floor(Math.random() * words.length)].toUpperCase();
|
||||
var gameAnswered = new Array(gameWord.length + 1).join('-')
|
||||
|
||||
window.onload = function()
|
||||
{
|
||||
console.log(gameWord)
|
||||
document.getElementById("WORD").innerHTML = gameAnswered;
|
||||
document.getElementById("lives").innerHTML = lives;
|
||||
}
|
||||
|
||||
function wrong()
|
||||
{
|
||||
lives -= 1;
|
||||
document.getElementById("lives").innerHTML = lives;
|
||||
}
|
||||
|
||||
function offChar(char)
|
||||
{
|
||||
if (gameAnswered.split('').indexOf('-') == -1)
|
||||
{
|
||||
alert('You Win');
|
||||
return;
|
||||
}
|
||||
|
||||
if (lives == 0) {
|
||||
alert('You dead');
|
||||
return;
|
||||
}
|
||||
|
||||
var indices = [];
|
||||
var idx = gameWord.split('').indexOf(char)
|
||||
if (idx == -1)
|
||||
{
|
||||
wrong();
|
||||
return;
|
||||
}
|
||||
|
||||
while (idx != -1)
|
||||
{
|
||||
indices.push(idx);
|
||||
idx = gameWord.split('').indexOf(char, idx + 1);
|
||||
}
|
||||
console.log(indices)
|
||||
|
||||
indices.forEach(function(item, indices)
|
||||
{
|
||||
var wordArray = gameAnswered.split('')
|
||||
wordArray[item] = char;
|
||||
gameAnswered = wordArray.join('');
|
||||
document.getElementById("WORD").innerHTML = gameAnswered;
|
||||
})
|
||||
}
|
||||
</script>
|
||||
<script type="text/javascript" src="game.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1 +0,0 @@
|
||||
<button onclick="offChar('A')">A</button><button onclick="offChar('B')">B</button><button onclick="offChar('C')">C</button><button onclick="offChar('D')">D</button><button onclick="offChar('E')">E</button><button onclick="offChar('F')">F</button><button onclick="offChar('G')">G</button><button onclick="offChar('H')">H</button><button onclick="offChar('I')">I</button><button onclick="offChar('J')">J</button><button onclick="offChar('K')">K</button><button onclick="offChar('L')">L</button><button onclick="offChar('M')">M</button><button onclick="offChar('N')">N</button><button onclick="offChar('O')">O</button><button onclick="offChar('P')">P</button><button onclick="offChar('Q')">Q</button><button onclick="offChar('R')">R</button><button onclick="offChar('S')">S</button><button onclick="offChar('T')">T</button><button onclick="offChar('U')">U</button><button onclick="offChar('V')">V</button><button onclick="offChar('W')">W</button><button onclick="offChar('X')">X</button><button onclick="offChar('Y')">Y</button><button onclick="offChar('Z')">Z</button>
|
BIN
html/screen.png
Normal file
BIN
html/screen.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
56
html/styles.css
Normal file
56
html/styles.css
Normal file
@ -0,0 +1,56 @@
|
||||
* {
|
||||
margin: 0; padding: 0; outline: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
color: #032137;
|
||||
background-color: #29516D;
|
||||
font-family: 'Vegur';
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
.wrap {
|
||||
max-width: 400px;
|
||||
margin: 10px auto;
|
||||
}
|
||||
|
||||
div.word {
|
||||
padding: 8px;
|
||||
border-top: 1px solid #032137;
|
||||
}
|
||||
|
||||
div.lives {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
div.word, div.lives {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
div.keyboard {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
div.keyboard button {
|
||||
color: #032137;
|
||||
font-family: 'Vegur';
|
||||
border-radius: 4px;
|
||||
font-size: 16px;
|
||||
background-color: #708EA4;
|
||||
padding: 8px;
|
||||
border: 1px solid #032137;
|
||||
box-sizing: border-box;
|
||||
margin: 2px;
|
||||
}
|
||||
|
||||
div.keyboard button:disabled {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
footer {
|
||||
border-top: 1px solid #032137;
|
||||
padding: 8px;
|
||||
margin-top: 20px;
|
||||
text-align: center;
|
||||
font-size: 16px;
|
||||
}
|
Loading…
Reference in New Issue
Block a user