Skip to content

Commit 277188e

Browse files
Changed Lots
- All but first coloured text is colored - Font is changed - Text moves randomly - Added more comments - Changed time to 20s - Played some more (181!)
1 parent b66f5cb commit 277188e

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

assets/capcha.ttf

123 KB
Binary file not shown.

html/game.html

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
-o-background-size: cover;
1717
background-size: cover;
1818
}
19+
@font-face {
20+
font-family: captcha;
21+
src: url("capcha.ttf");
22+
}
1923
</style>
2024
<!-- Latest compiled and minified CSS -->
2125
<link rel="stylesheet" href="https://bootswatch.com/cyborg/bootstrap.min.css" crossorigin="anonymous">
@@ -26,7 +30,7 @@
2630
<center>
2731
<br>
2832
<br>
29-
<h1 class="words">
33+
<h1 class="words" style="font-family: captcha">
3034

3135
</h1>
3236
<h1 class="win">
@@ -56,11 +60,23 @@ <h1 class="win2" style="display: none">
5660
for (key in bases){ // Go throught fruit objects
5761
if (!bases.hasOwnProperty(key)) continue; // If the current iteration is on a builtin property to a prototype, skip
5862
out.push(key) // Else, add the name of fruit to Array
63+
color(bases[key].replace("url('", "").replace("')", ""))
64+
color(bases[key].replace("url('", "").replace("')", "")) // HACK: Preload the image so it won't be black on first attempt
5965
}
6066
function choose(choices) { // Makes a random choice from Array, eg. [1,2,5] => 1 or 2 or 5
6167
var index = Math.floor(Math.random() * choices.length);
6268
return choices[index];
6369
}
70+
function randomMove(elem){ // Takes a jQuery element like $(".words") and puts it in a random location
71+
var posx = (Math.random() * ($(document).width() - 200)).toFixed(); // Chooses a random x
72+
var posy = (Math.random() * ($(document).height() - 50)).toFixed(); // Chooses a random Y
73+
elem.css({ // Sets the css of the element
74+
'position':'absolute', // To the absolute position of x and y
75+
'left':posx+'px',
76+
'top':posy+'px',
77+
'display':'inline'
78+
})
79+
}
6480
var mappings = { // Mappings of keys to fruits
6581
KeyA: "lemon", // TODO: Move to config?
6682
KeyW: "bannana",
@@ -72,7 +88,8 @@ <h1 class="win2" style="display: none">
7288
function initPic(pic, word) { // Function that sets the background and word
7389
$("html").css("background-image", pic); // TODO: Random location for word?
7490
$(".words").text(word);
75-
$(".words").css("color", color(pic.replace("url('", "").replace("')", "")))
91+
$(".words").css("color", color(pic.replace("url('", "").replace("')", "")));
92+
randomMove($(".words")) // CHANGED: Now moves text each time
7693
current.pic = pic;
7794
current.word = word;
7895
}
@@ -92,7 +109,7 @@ <h1 class="win2" style="display: none">
92109
showLoaderOnConfirm: true,
93110
allowOutsideClick: false
94111
}).then(function (name) { // Then when user clicks submit
95-
$.ajax({
112+
$.ajax({ // TODO: This method is a bit hacky HACK
96113
url: '/add-score/', // Make a web request to index.js with
97114
type: 'post',
98115
data: {},
@@ -113,7 +130,7 @@ <h1 class="win2" style="display: none">
113130
});
114131
})
115132
document.onkeyup = function () {}; // Finally, set the "onkeyup" function to empty so that users can't continue playing
116-
}, 60000)
133+
}, 20000)
117134

118135
var rounds = 0; // Start at 0 wins
119136
initPic(bases[choose(out)], choose(out)) // Set a random background and text

storage/leaderboard.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[{"name":"Jeff","score":0},{"name":"Jay","score":6},{"name":"Jay","score":53}]
1+
[{"name":"Jeff","score":0},{"name":"Jay","score":6},{"name":"Jay","score":53},{"name":"Yipee","score":181},{"name":"Banana","score":16}]

0 commit comments

Comments
 (0)