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 ">
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
0 commit comments