Skip to content

Commit

Permalink
Added snake demo
Browse files Browse the repository at this point in the history
  • Loading branch information
dubrowgn committed Sep 15, 2014
1 parent 8be0c31 commit 39e81c6
Show file tree
Hide file tree
Showing 16 changed files with 210 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ Thumbs.db
############################
.*

# sublime project files
*.sublime-*
Empty file modified build.php
100755 → 100644
Empty file.
6 changes: 3 additions & 3 deletions src/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,12 @@ Impulse.Util = (function() {
};
} // if
else {
var start = new Date() | 0;
Timing.now = function() { return (new Date() | 0) - start; };
var start = Date.now();
Timing.now = function() { return Date.now() - start; };
} // else

return Timing;
})();

return Util;
});
});
2 changes: 1 addition & 1 deletion web/demos.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/html" xmlns="http://www.w3.org/1999/html">
<head>
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
<link rel="shortcut icon" type="image/x-icon" href="img/shooter-icon.png" />
<meta charset="UTF-8" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="keywords" content="Impulse, Impulse.js, JavaScript, Game Engine, HTML5, Canvas" />
Expand Down
Binary file added web/demos/snake/assets/optimize/berry.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/demos/snake/assets/optimize/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/demos/snake/assets/optimize/segment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 66 additions & 0 deletions web/demos/snake/css/global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
.layer { position:absolute; }
html {
height: 100%;
}
body {
color:#fff;
text-shadow: 1px 1px 4px #000;
font-family: helvetica;
background-color: #333;
margin: 0;
height: 100%;
}
a:link, a:active, a:visited {
color: #0080ff;
text-decoration: none;
}
a:hover {
color: #fff;
}
.hidden {
display: none;
}
.ui {
padding:2px;
color:#fff;
text-shadow: 1px 1px 4px #000;
box-sizing: border-box;
background-color: rgba(0, 0, 0, 0.4);
font-weight: bold;
position: absolute;
width: 100%;
text-align: center;
}
.lg, h1 {
font-size:48pt;
}
.sm, h2 {
font-size:18pt;
}
.xsm, h3 {
font-size:14pt;
}
.left {
text-align: left;
}
.right {
text-align: right;
}
.top {
top: 0;
}
.bottom {
bottom: 0;
}
.menu-container {
position: absolute;
width: 100%;
height: 100%;
text-align: center;
z-index: 1;
background-color: #333;
}
.ui-2nd {
background: none;
padding: 4px;
}
36 changes: 36 additions & 0 deletions web/demos/snake/lib/require.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 49 additions & 0 deletions web/demos/snake/snake.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html>
<head>
<title>Snake!</title>
<link rel="shortcut icon" type="image/x-icon" href="assets/optimize/icon.png" />
<link rel="stylesheet" type="text/css" href="css/global.css">
<script type="text/javascript" src="lib/require.min.js" data-main="src/main" charset="utf-8"></script>
</head>
<body>
<!-- GAME MENU - table was the fastest/easiest way to center content -->
<table id="ui_menu" class="menu-container">
<tr>
<td class="bg">
<h1>Snake!</h1>
<p>
<h2>In-Game Keys:</h2>
<div>space: pause/unpause</div>
<div>f: toggle fullscreen</div>
<div>left mouse: reset game</div>
<div>arrow keys: change direction</div>
</p>
<p>
<h2>Difficulty:</h2>
<label><input type="radio" name="difficulty" value="0.5" />slow</label>
<label><input type="radio" name="difficulty" value="1.0" checked />normal</label>
<label><input type="radio" name="difficulty" value="2.0" />fast</label>
</p>
<p>
<h2>Map Size:</h2>
<label><input type="radio" name="size" value="14,10" />tiny</label>
<label><input type="radio" name="size" value="21,15" checked />normal</label>
<label><input type="radio" name="size" value="28,20" />large</label>
</p>
<p><input id="btn_play" type="button" value="Play!"/></p>
</td>
</tr>
<table>

<!-- RENDER TARGET - canvas for the game to use as 2D render target -->
<canvas id="layer1" class="layer"></canvas>

<!-- GAME UI - use HTML to describe game UI, and update it by listening to game event delegates -->
<div id="ui_paused" class="ui top lg">PAUSED<div class="xsm">Press space to unpause</div></div>
<div id="ui_lost" class="ui top lg hidden">YOU LOSE!<div class="xsm">Click the board to reset</div></div>
<div id="ui_score" class="ui bottom sm">Score: <span id="ui_score_value">&mdash;</span></div>
<div class="ui ui-2nd bottom right xsm">High Score: <span id="ui_highScore_value">&mdash;</span></div>
<div class="ui ui-2nd bottom left xsm"><a id="quit" href="#">Exit</a></div>
</body>
</html>
43 changes: 43 additions & 0 deletions web/demos/snake/src/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/documentation.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/html" xmlns="http://www.w3.org/1999/html">
<head>
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
<link rel="shortcut icon" type="image/x-icon" href="img/shooter-icon.png" />
<meta charset="UTF-8" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="keywords" content="Impulse, Impulse.js, JavaScript, Game Engine, HTML5, Canvas" />
Expand Down
2 changes: 1 addition & 1 deletion web/download.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/html" xmlns="http://www.w3.org/1999/html">
<head>
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
<link rel="shortcut icon" type="image/x-icon" href="img/shooter-icon.png" />
<meta charset="UTF-8" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="keywords" content="Impulse, Impulse.js, JavaScript, Game Engine, HTML5, Canvas" />
Expand Down
Binary file added web/img/shooter-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/snake.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 39e81c6

Please sign in to comment.