Browse Source

something works somewhat

master
mort 6 years ago
commit
6d4d526027
6 changed files with 101 additions and 0 deletions
  1. 1
    0
      .gitignore
  2. BIN
      assets/loading.gif
  3. 76
    0
      index.html
  4. 2
    0
      js/sections/browser.js
  5. 15
    0
      package.json
  6. 7
    0
      style.css

+ 1
- 0
.gitignore View File

@@ -0,0 +1 @@
node_modules

BIN
assets/loading.gif View File


+ 76
- 0
index.html View File

@@ -0,0 +1,76 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="sections">
<div class="loading hidden">
<img src="assets/loading.gif">
</div>

<div class="error hidden">
Error: Couldn't connect to server.
</div>

<div class="pre hidden">
<button id="play-god">Play as God</button>
<button id="play-runner">Play as Runner</button>
</div>

<div class="game hidden">
<canvas id="game-canvas"></canvas>
</div>
</div>

<script src="node_modules/jquery/dist/jquery.min.js"></script>
<script src="node_modules/socksugar/client.js"></script>

<script>
window.page = {
switchTo: function(name) {
if (page.switchTo.prev)
page.switchTo.prev.addClass("hidden");

var elem = $("#sections > ."+name);
console.log(elem);
elem.removeClass("hidden");
page.switchTo.prev = elem;
}
}

//Start with showincg a loading animation
page.switchTo("loading");

//Initiate a socket connection
window.sock = new SockSugar("ws://localhost:8081");

//If we can't connect to the server, display an error
var errTimeout = setTimeout(function() {
page.switchTo("error");
}, 7000);

sock.on("ready", function() {
clearTimeout(errTimeout);
page.switchTo("pre");

$("#play-god").on("click", function() {
page.switchTo("loading");
sock.send("startgame/god", {}, function(err, res) {
console.log(err, res);
});
});

$("#play-runner").on("click", function() {
page.switchTo("loading");
sock.send("startgame/runner", {}, function(err, res) {
console.log(err, res);
});
});
});
</script>

<script src="sections/browser.js"></script>
</body>
</html>

+ 2
- 0
js/sections/browser.js View File

@@ -0,0 +1,2 @@
sections.browser.createRoute({
name:

+ 15
- 0
package.json View File

@@ -0,0 +1,15 @@
{
"name": "ldcli",
"version": "0.0.0",
"description": "The client for my ludumdare game.",
"main": "index.html",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Martin Dørum Nygaard",
"license": "GPL-2.0",
"dependencies": {
"jquery": "^2.1.4",
"socksugar": "^0.2.0"
}
}

+ 7
- 0
style.css View File

@@ -0,0 +1,7 @@
.hidden {
display: none;
}

#sections > div {
position: absolute;
}

Loading…
Cancel
Save