Skip to content

Commit

Permalink
added the UI for displaying game events #12
Browse files Browse the repository at this point in the history
  • Loading branch information
Puyush6889 committed Jan 10, 2018
1 parent 43c0a66 commit 01731f3
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
<script type="text/javascript" src="/static/index.js"></script>
</head>
<body>
<canvas id="canvas"></canvas>
<div class="game">
<canvas id="canvas"></canvas>
</div>
<div class="messagesContainer">

This comment has been minimized.

Copy link
@vinnyoodles

vinnyoodles Jan 10, 2018

Owner

name the class message_container

<h2>Game</h2>
<div class="messages" id="commands"></div>
</div>
</body>
</html>
19 changes: 18 additions & 1 deletion src/static/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ function onLoad(event) {
var json = JSON.parse(event.data);
switch (json.event) {
case 'metadata': return setCanvas(json.width, json.height);
default: console.log(json);
default: gameEvents(json);

}
} catch (err) {
Raven.captureException(err)
Expand All @@ -45,6 +46,22 @@ function onLoad(event) {
}
}

function gameEvents(json) {

This comment has been minimized.

Copy link
@vinnyoodles

vinnyoodles Jan 10, 2018

Owner

Functions should be named as an action, as in what it is doing.

var parent = document.getElementById('commands');
var child = document.createElement('p');
switch (json.event) {
case 'last log':
var html = "<p>" + json.data + "</p>";
child.innerHTML = html;
parent.appendChild(child);
break;
case 'all logs':
break;

default: //no gets updated

This comment has been minimized.

Copy link
@vinnyoodles

vinnyoodles Jan 10, 2018

Owner

"no gets updated"?!

This comment has been minimized.

Copy link
@Puyush6889

Puyush6889 Jan 10, 2018

Author Collaborator

rip, should've been "The UI shouldn't get updated"


}

function onKey(event) {
if (!connected)
Raven.captureMessage('Client is not connected to websocket');
Expand Down
19 changes: 17 additions & 2 deletions src/static/main.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
body {
background-color: #252227;
}

.game {
float: left;
}
#canvas {
padding: 0;
top: 0;
Expand All @@ -10,4 +12,17 @@ body {
right: 0;
margin: auto;
position: absolute;
}
}
.messagesContainer {
float: right;
height: 250px;
width: 250px;
padding: 3px;
background:#D3D3D3;
height: 100vh;
}
.messages {
height: 95vh;
overflow: auto;
background: #fff;
}

This comment has been minimized.

Copy link
@vinnyoodles

vinnyoodles Jan 10, 2018

Owner

indentation

0 comments on commit 01731f3

Please sign in to comment.