Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 67bb63d
Showing
15 changed files
with
326 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Chronicle | ||
|
||
## TODO: | ||
|
||
- Create tools for easier development workflow. (Cakefile?) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
(() -> | ||
lastTime = 0 | ||
vendors = ['ms', 'moz', 'webkit', 'o'] | ||
x = 0 | ||
while x < vendors.length && !window.requestAnimationFrame | ||
window.requestAnimationFrame = window["#{vendors[x]}RequestAnimationFrame"] | ||
window.cancelAnimationFrame = window["#{vendors[x]}CancelAnimationFrame"] || | ||
window["#{vendors[x]}CancelRequestAnimationFrame"] | ||
x++ | ||
|
||
if not window.requestAnimationFrame | ||
window.requestAnimationFrame = (callback, element) -> | ||
currentTime = new Date().getTime() | ||
timeToCall = Math.max(0, 16 - (currentTime - lastTime)) | ||
id = window.setTimeout () -> | ||
callback(currentTime + timeToCall) | ||
, timeToCall | ||
lastTime = currentTime + timeToCall | ||
id | ||
|
||
if not window.cancelAnimationFrame | ||
window.cancelAnimationFrame = (id) -> | ||
clearTimeout(id) | ||
)() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
canvas = document.getElementById 'game' | ||
context = canvas.getContext '2d' | ||
|
||
socket = new io.connect 'http://localhost:8100' | ||
|
||
# Main class to handle keystroes | ||
class KeyMaster | ||
@UP = 'UP' | ||
@RIGHT = 'RIGHT' | ||
@DOWN = 'DOWN' | ||
@LEFT = 'LEFT' | ||
|
||
constructor: () -> | ||
# Keycode map | ||
@Keys = | ||
37: KeyMaster.LEFT | ||
38: KeyMaster.UP | ||
39: KeyMaster.RIGHT | ||
40: KeyMaster.DOWN | ||
|
||
# Handler for a keystroke event | ||
handleStroke: (event) -> | ||
if event? | ||
keyCode = event.keyCode | ||
else | ||
keyCode = window.event.keyCode | ||
|
||
socket.send @Keys[keyCode] | ||
|
||
# Main game class | ||
class Chronicle | ||
constructor: (@players) -> | ||
|
||
|
||
socket.on 'news', (data) -> | ||
console.log data | ||
socket.emit 'my other event', my: 'data' |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
(() -> | ||
logo = $ '#logo' | ||
unless logo.length > 0 | ||
return | ||
|
||
logo.css 'opacity', 1.0 | ||
logo.data 'blink', false | ||
|
||
updateLogo = () -> | ||
opacity = parseFloat(logo.css('opacity')).toFixed(2) | ||
opacity = parseFloat(opacity) | ||
|
||
if logo.data().blink == true | ||
opacity += 0.02 | ||
else | ||
opacity -= 0.02 | ||
|
||
if opacity >= 1.00 | ||
logo.data 'blink', false | ||
opacity = 1.00 | ||
else if opacity <= 0.2 | ||
logo.data 'blink', true | ||
opacity = 0.2 | ||
|
||
opacity = opacity.toFixed(2) | ||
|
||
requestAnimationFrame updateLogo | ||
logo.css 'opacity', opacity | ||
updateLogo() | ||
)() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "chronicle", | ||
"description": "An mmorpg game built with nodejs", | ||
"author": "Nico Hämäläinen <nico@bender.fi>", | ||
"version": "0.0.0", | ||
"license": "MIT", | ||
|
||
"dependencies": { | ||
"express" : "3.x", | ||
"socket.io": "0.9.x" | ||
}, | ||
|
||
"engine": "node >= 0.8.8" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Chronicle</title> | ||
<style type="text/css"> | ||
html, body { | ||
margin: 0; | ||
padding: 0; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
body { | ||
background: #3c3d3d url('assets/img/body.png') repeat center center; | ||
} | ||
#logo { | ||
position: absolute; | ||
width: 680px; | ||
height: 120px; | ||
left: 50%; | ||
top: 50%; | ||
margin-left: -340px; | ||
margin-top: -60px; | ||
} | ||
</style> | ||
<script src="assets/js/lib/jquery.min.js"></script> | ||
<script src="/socket.io/socket.io.js"></script> | ||
</head> | ||
<body> | ||
<img id="logo" src="assets/img/logo.png" alt="Chronicle Logo"> | ||
<script src="assets/js/app.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Chronicle</title> | ||
<style type="text/css"> | ||
html, body { | ||
margin: 0; | ||
padding: 0; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
body { | ||
background: #3c3d3d url('assets/img/body.png') repeat center center; | ||
} | ||
#map { | ||
width: 100%; | ||
height: 100%; | ||
} | ||
</style> | ||
<script src="assets/js/lib/jquery.min.js"></script> | ||
<script src="/socket.io/socket.io.js"></script> | ||
</head> | ||
<body> | ||
<canvas id="game"></canvas> | ||
<script src="assets/js/app.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
express = require 'express' | ||
app = express() | ||
http = require 'http' | ||
server = http.createServer(app) | ||
io = require('socket.io').listen(server) | ||
|
||
server.listen 8100 | ||
|
||
app.use '/assets', express.static "#{__dirname}/assets" | ||
|
||
# Main index page | ||
app.get '/', (request, response) -> | ||
response.sendfile "#{__dirname}/public/index.html" | ||
|
||
# Map test page | ||
app.get '/map', (request, response) -> | ||
response.sendfile "#{__dirname}/public/map.html" | ||
|
||
io.sockets.on 'connection', (socket) -> | ||
socket.emit 'news', hello: 'world' | ||
socket.on 'my other event', (data) -> | ||
console.log data |
Empty file.