-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
146 lines (113 loc) · 5.14 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Game of Life</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<!-- Place favicon.ico and apple-touch-icon.png in the root directory: mathiasbynens.be/notes/touch-icons -->
<link rel="stylesheet" href="css/style.css">
<link href='http://fonts.googleapis.com/css?family=PT+Sans|PT+Serif' rel='stylesheet' type='text/css'>
<script src="js/libs/modernizr-2.5.0.min.js"></script>
</head>
<body>
<!--[if lt IE 7]><p class=chromeframe>Your browser is <em>ancient!</em> <a href="http://browsehappy.com/">Upgrade to a different browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to experience this site.</p><![endif]-->
<div id="page_wrapper">
<header>
<h1>Persistent World Multiplayer Conway's Game of Life</h1>
</header>
<div role="main" id="main_wrapper">
<a href="https://github.com/tkbremnes/Persistent-World-Multiplayer-Conway-s-Game-of-Life"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://a248.e.akamai.net/assets.github.com/img/7afbc8b248c68eb468279e8c17986ad46549fb71/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub"></a>
<div id="gol_wrapper">
<canvas width="400" height="304" id="canvas"></canvas>
</div>
<div id="button_wrapper">
<button onclick="start()" id="startButton">Start</button>
<button onclick="pause()" id="pauseButton">Pause</button>
<button onclick="resetBoard()" id="resetButton">Reset</button>
</div>
<p id="status"><span class="statusStar">✪</span> <span id="statusText">STATUS</span> <span class="statusStar">✪</span></p>
<div>
<p>This experiment is built using <a href="http://nodejs.org/">node.js</a> and <a href="http://socket.io">socket.io</a>. Thanks to <a href="http://html5boilerplate.com/">HTML5 Boilerplate</a>.</p>
<h2>The rules</h2>
<p><em>Game of Life</em> is a "cellular automaton" that plays itself according to four simple rules:
<ol>
<li>Any live cell with fewer than two live neighbours dies, as if caused by under-population.
<li>Any live cell with two or three live neighbours lives on to the next generation.
<li>Any live cell with more than three live neighbours dies, as if by overcrowding.
<li>Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.
</ol>
<a href="http://en.wikipedia.org/wiki/Conway's_Game_of_Life">Source: Wikipedia</a>.</p>
</div>
</div>
</div>
<footer id="disclaimer">
<p>This is a thingamabob by <a href="http://twitter.com/kartoffelmos">@kartoffelmos</a>
</footer>
<script src="js/script.js"></script>
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io.connect('http://129.241.127.32:1337');
socket.on('init', function(data)
{
console.log("init message received, starting...");
board = data.board;
running = data.running;
noOfCellsHorizontal = data.noOfCellsHorizontal;
noOfCellsVertical = data.noOfCellsVertical;
cellSize = data.cellSize;
init();
});
socket.on('receive_click', function (data)
{
console.log("click received");
toggleCell(data.x, data.y);
drawBoard();
});
socket.on('status', function (data)
{
console.log(data.running);
running = data.running;
updateStatus();
});
socket.on('tick', function()
{
console.log("tick received!");
gameTick();
drawBoard();
});
socket.on('helloworld', function()
{
console.log("hello world!");
});
socket.on('sync', function(data)
{
board = data.board;
});
socket.on('connections', function(data){
// do something
});
</script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.1.min.js"><\/script>')</script>
<script src="js/plugins.js"></script>
<!-- <script src="js/script.js"></script>-->
<script>
var _gaq=[['_setAccount','UA-XXXXX-X'],['_trackPageview']];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
s.parentNode.insertBefore(g,s)}(document,'script'));
</script>
<script>
$(document).ready(function(){
stopLoadingAnimation();
console.log("sending ready signal");
socket.emit('client_ready', {client: 'ready'});
});
</script>
</body>
</html>