Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into best-score
Browse files Browse the repository at this point in the history
Conflicts:
	index.html
	js/application.js
	js/html_actuator.js
  • Loading branch information
TimPetricola committed Mar 11, 2014
2 parents d6da8d9 + 39ba3a9 commit 7765445
Show file tree
Hide file tree
Showing 9 changed files with 459 additions and 141 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ Made just for fun. [Play it here!](http://gabrielecirulli.github.io/2048/)

[![Screenshot](http://pictures.gabrielecirulli.com/2048-20140309-234100.png)](http://pictures.gabrielecirulli.com/2048-20140309-234100.png)

That screenshot is fake by, the way. I never reached 2048 :smile:
That screenshot is fake, by the way. I never reached 2048 :smile:

## Contributing
Changes and improvements are more than welcome! Feel free to fork and open a pull request. Please make your changes in a specifically made branch and request to pull on `master`! If you can, please make sure the game fully works before sending the PR, as that will help speed up the process.
Changes and improvements are more than welcome! Feel free to fork and open a pull request. Please make your changes in a specific branch and request to pull into `master`! If you can, please make sure the game fully works before sending the PR, as that will help speed up the process.

You can find the same information in the [contributing guide.](https://github.com/gabrielecirulli/2048/blob/master/CONTRIBUTING.md)

## License
2048 is licensed under the [MIT license.](https://github.com/gabrielecirulli/2048/blob/master/LICENSE.txt)

## Donations
I made this in my spare time, and it's hosted on GitHub (which means I don't have any hosting costs), but if you enjoyed the game and feel like buying me coffee, you can donate at my BTC address: `1Ec6onfsQmoP9kkL3zkpB6c5sA4PVcXU2i`. Thank you very much!
Binary file added favicon.ico
Binary file not shown.
22 changes: 12 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,7 @@
<title>2048</title>

<link href="style/main.css" rel="stylesheet" type="text/css">

<script src="js/hammer.min.js"></script>
<script src="js/keyboard_input_manager.js"></script>
<script src="js/html_actuator.js"></script>
<script src="js/grid.js"></script>
<script src="js/tile.js"></script>
<script src="js/local_score_manager.js"></script>
<script src="js/game_manager.js"></script>
<script src="js/application.js"></script>
<link rel="shortcut icon" href="favicon.ico">

<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
Expand Down Expand Up @@ -75,8 +67,18 @@ <h1 class="title">2048</h1>
</p>
<hr>
<p>
Created by <a href="http://gabrielecirulli.com" target="_blank">Gabriele Cirulli.</a> Based on <a href="https://itunes.apple.com/us/app/1024!/id823499224" target="_blank">1024 by Veewo Studio.</a>
Created by <a href="http://gabrielecirulli.com" target="_blank">Gabriele Cirulli.</a> Based on <a href="https://itunes.apple.com/us/app/1024!/id823499224" target="_blank">1024 by Veewo Studio</a> and conceptually similar to <a href="http://asherv.com/threes/" target="_blank">Threes by Asher Vollmer.</a>
</p>
</div>

<script src="js/animframe_polyfill.js"></script>
<script src="js/hammer.min.js"></script>
<script src="js/keyboard_input_manager.js"></script>
<script src="js/html_actuator.js"></script>
<script src="js/grid.js"></script>
<script src="js/tile.js"></script>
<script src="js/local_score_manager.js"></script>
<script src="js/game_manager.js"></script>
<script src="js/application.js"></script>
</body>
</html>
26 changes: 26 additions & 0 deletions js/animframe_polyfill.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
(function() {
var lastTime = 0;
var vendors = ['webkit', 'moz'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
window.cancelAnimationFrame =
window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame'];
}

if (!window.requestAnimationFrame) {
window.requestAnimationFrame = function(callback, element) {
var currTime = new Date().getTime();
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
timeToCall);
lastTime = currTime + timeToCall;
return id;
};
}

if (!window.cancelAnimationFrame) {
window.cancelAnimationFrame = function(id) {
clearTimeout(id);
};
}
}());
8 changes: 3 additions & 5 deletions js/application.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
document.addEventListener("DOMContentLoaded", function () {
// Wait till the browser is ready to render the game (avoids glitches)
window.requestAnimationFrame(function () {
new GameManager(4, KeyboardInputManager, HTMLActuator, LocalScoreManager);
});
// Wait till the browser is ready to render the game (avoids glitches)
window.requestAnimationFrame(function () {
new GameManager(4, KeyboardInputManager, HTMLActuator, LocalScoreManager);
});
8 changes: 6 additions & 2 deletions js/keyboard_input_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@ KeyboardInputManager.prototype.listen = function () {
75: 0, // vim keybindings
76: 1,
74: 2,
72: 3
72: 3,
87: 0, // W
68: 1, // D
83: 2, // S
65: 3 // A
};

document.addEventListener("keydown", function (event) {
var modifiers = event.altKey && event.ctrlKey && event.metaKey &&
var modifiers = event.altKey || event.ctrlKey || event.metaKey ||
event.shiftKey;
var mapped = map[event.which];

Expand Down
7 changes: 7 additions & 0 deletions style/helpers.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,10 @@
-webkit-animation-fill-mode: #{$str};
-moz-animation-fill-mode: #{$str};
}

// Media queries
@mixin smaller($width) {
@media screen and (max-width: $width) {
@content;
}
}
Loading

0 comments on commit 7765445

Please sign in to comment.