-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweb.js
78 lines (68 loc) · 1.63 KB
/
web.js
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
/*
=================================================
Phase Ball
Tai Rodrig
April 2014
MAIN NODE ENTRY
=================================================
*/
var express = require("express");
var logfmt = require("logfmt");
var path = require('path');
var $ = require("jquery");
var app = express();
app.use(express.static(__dirname + '/public'));
app.set('views', __dirname + '/views');
app.engine('html', require('ejs').renderFile);
app.use(express.bodyParser());
app.use(logfmt.requestLogger());
app.configure('development', function(){
app.use(express.errorHandler());
});
app.get('/challenge/:num', function(req, res) {
var num = req.params.num;
console.log("num "+num+"!!!");
res.render('challenge.html', {
title: "Challenge "+num,
game: {
balls: [
{x:4, y:7},
{x:5, y:6},
{x:3, y:4},
{x:4.5, y:5},
],
board: {x:2, y:1, width:16, height:14},
goal: {x:8, y:5, width:0.5,height:1.5},
obstacles: [
{x:7, y:4, width:0.2,height:2},
{x:5.5, y:6, width:0.8,height:0.3}
]
}
});
});
app.get('/create', function(req, res) {
res.render('levelcreator.html', {
title: "Create new level",
game: {
balls: [
{x:4, y:7},
{x:5, y:6},
{x:3, y:4},
{x:4.5, y:5},
],
board: {x:2, y:1, width:16, height:14},
goal: {x:8, y:5, width:0.5,height:1.5},
obstacles: [
{x:7, y:4, width:0.2,height:2},
{x:5.5, y:6, width:0.8,height:0.3}
]
}
});
});
app.get('/info', function(req, res) {
res.render('info.html', {});
});
var port = Number(process.env.PORT || 5000);
app.listen(port, function() {
console.log("Listening on " + port);
});