Skip to content
Snippets Groups Projects
Commit 0494fc82 authored by Hameed Andy's avatar Hameed Andy
Browse files

Original Project

parent a496b221
No related branches found
No related tags found
No related merge requests found
Showing
with 1372 additions and 0 deletions
Copyright © Patrick Gillespie, http://patorjk.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
JavaScript Snake<br/>
By Patrick Gillespie<br/>
License: MIT<br/>
http://patorjk.com/games/snake
This is a DOM-based game of Snake that I wrote in JavaScript a few years back.
Other than the full screen mode demonstrated in the code, it can also be
initialized in div tags within a page. Example:
var mySnakeBoard = new SNAKE.Board( {
boardContainer: "game-area",
fullScreen: false,
width: 580,
height:400
});
The comments are formatted a little strange because at the time I was playing
around with YUI Doc.
/*
JavaScript Snake
By Patrick Gillespie
http://patorjk.com/games/snake
*/
select {
border: black;
color: #3E2E44;
background: black;
}
button {
border: black;
color: #3E2E44;
background: black;
}
body {
margin:0px;
padding:0px;
}
#game-area {
margin:0px;
padding:0px;
}
#high-score {
position: relative;
left: 200px;
bottom: 50px;
}
#game-area:focus { outline: none; }
#mode-wrapper {
font-family: Verdana, arial, helvetica, sans-serif;
font-size: 14px;
color: black;
}
a.snake-link, a.snake-link:link, a.snake-link:visited {
color: black;
}
a.snake-link:hover {
color: #3E2E44;
}
.snake-pause-screen {
font-family: Verdana, arial, helvetica, sans-serif;
font-size: 14px;
position:absolute;
width:300px;
height:80px;
text-align:center;
top:50%;
left:50%;
margin-top:-40px;
margin-left:-150px;
display:none;
background-color:#3E2E44;
color:black;
}
.snake-panel-component {
position: absolute;
font-family: Verdana, arial, helvetica, sans-serif;
font-size: 14px;
color: black;
text-align: center;
background-color: #3E2E44;
padding: 8px;
margin: 0px;
}
.snake-snakebody-block {
margin: 0px;
padding: 0px;
background-color: #3E2E44;
position: absolute;
border: 0px solid black;
background-repeat: no-repeat;
}
.snake-snakebody-alive {
background-image: url('./images/dark-snakeblock.png');
}
.snake-snakebody-dead {
background-image: url('./images/dead-dark-snakeblock.png');
}
.snake-food-block {
margin: 0px;
padding: 0px;
background-color: black;
border: 2px solid #3E2E44;
position: absolute;
}
.snake-playing-field {
margin: 0px;
padding: 0px;
position: absolute;
background-color: #312E44;
border: 3px solid black;
}
.snake-game-container {
margin: 0px;
padding: 0px;
border-width: 0px;
border-style: none;
zoom: 1;
background-color: #3E2E44;
position: relative;
}
.snake-welcome-dialog {
padding: 8px;
margin: 0px;
background-color: black;
color: #3E2E44;
font-family: Verdana, arial, helvetica, sans-serif;
font-size: 14px;
position: absolute;
top: 50%;
left: 50%;
width: 300px;
/*height: 150px;*/
margin-top: -100px;
margin-left: -158px;
text-align: center;
display: block;
}
.snake-try-again-dialog {
padding: 8px;
margin: 0px;
background-color: black;
color: #312E44;
font-family: Verdana, arial, helvetica, sans-serif;
font-size: 14px;
position: absolute;
top: 50%;
left: 50%;
width: 300px;
height: 100px;
margin-top: -75px;
margin-left: -158px;
text-align: center;
display: none;
}
File added
Javascript_Snake_Original/css/images/dark-snakeblock.png

1.01 KiB

Javascript_Snake_Original/css/images/dead-dark-snakeblock.png

1.22 KiB

Javascript_Snake_Original/css/images/deadblock.png

240 B

Javascript_Snake_Original/css/images/deadblock_border.png

117 B

Javascript_Snake_Original/css/images/snakeblock.png

119 B

/*
JavaScript Snake
By Patrick Gillespie
http://patorjk.com/games/snake
*/
body {
margin:0px;
padding:0px;
}
#game-area {
margin:0px;
padding:0px;
}
#high-score {
position: relative;
left: 200px;
bottom: 50px;
}
#mode-wrapper {
color: #ffffff;
font-family: Verdana, arial, helvetica, sans-serif;
font-size: 14px;
}
#game-area:focus { outline: none; }
a.snake-link, a.snake-link:link, a.snake-link:visited {
color: #FCFC54;
}
a.snake-link:hover {
color: #FfFf54;
}
.snake-pause-screen {
font-family: Verdana, arial, helvetica, sans-serif;
font-size: 14px;
position:absolute;
width:300px;
height:80px;
text-align:center;
top:50%;
left:50%;
margin-top:-40px;
margin-left:-150px;
display:none;
background-color:black;
color:white;
}
.snake-panel-component {
position: absolute;
font-family: Verdana, arial, helvetica, sans-serif;
font-size: 14px;
color: #ffffff;
text-align: center;
background-color: #FC5454;
padding: 8px;
margin: 0px;
}
.snake-snakebody-block {
margin: 0px;
padding: 0px;
background-color: #FF0000;
position: absolute;
border: 0px solid #000080;
background-repeat: no-repeat;
}
.snake-snakebody-alive {
background-image: url('./images/snakeblock.png');
}
.snake-snakebody-dead {
background-image: url('./images/deadblock.png');
}
.snake-food-block {
margin: 0px;
padding: 0px;
background-color: #FF0000;
border: 0px solid #000080;
position: absolute;
}
.snake-playing-field {
margin: 0px;
padding: 0px;
position: absolute;
background-color: #0000A8;
border: 0px solid #0000A8;
}
.snake-game-container {
margin: 0px;
padding: 0px;
border-width: 0px;
border-style: none;
zoom: 1;
background-color: #FC5454;
position: relative;
}
.snake-welcome-dialog {
padding: 8px;
margin: 0px;
background-color: #000000;
color: #ffffff;
font-family: Verdana, arial, helvetica, sans-serif;
font-size: 14px;
position: absolute;
top: 50%;
left: 50%;
width: 300px;
/*height: 150px;*/
margin-top: -100px;
margin-left: -158px;
text-align: center;
display: block;
}
.snake-try-again-dialog {
padding: 8px;
margin: 0px;
background-color: #000000;
color: #ffffff;
font-family: Verdana, arial, helvetica, sans-serif;
font-size: 14px;
position: absolute;
top: 50%;
left: 50%;
width: 300px;
height: 100px;
margin-top: -75px;
margin-left: -158px;
text-align: center;
display: none;
}
<!DOCTYPE html>
<!--<html manifest="snake.appcache">-->
<head>
<!--
JavaScript Snake
By Patrick Gillespie
http://patorjk.com/games/snake
Source code is available here: https://github.com/patorjk/JavaScript-Snake
-->
<title>JavaScript Snake</title>
<link rel=stylesheet id=style type=text/css href=./css/main-snake.css />
<button onclick=getTheme()>Click to use this theme.</button>
<select id="select">
<option>Dark Theme</option>
<option>Revert To Original</option>
</select>
<div id="mode-wrapper">Select which mode you would like to play in.<br /><button id="Easy">Easy</button><br /><button id="Medium">Medium</button><br /><button id="Difficult">Difficult</button></div>
<button id="high-score">Get your current high score for this game.</button>
<script>
function getTheme () {
function changeTheme (Theme) {
document.getElementById('style').setAttribute('href', Theme);
}
var index = document.getElementById("select").selectedIndex;
switch (index) {
case 0:
changeTheme('css/dark-snake.css');
break;
case 1: changeTheme('css/main-snake.css');
}
}
if (navigator.onLine && window.location.hostname === 'patorjk.com') {
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-3312460-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
}
</script>
</head>
<body>
<div id="game-area" tabindex="0">
</div>
<script type="text/javascript" src="./js/snake.js"></script>
<script type="text/javascript">
var mySnakeBoard = new SNAKE.Board( {
boardContainer: "game-area",
fullScreen: true
});
</script>
</body>
</html>
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment