Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: karenc/fakesnladders
base: 6ba33a5f1b
...
head fork: karenc/fakesnladders
compare: 756c68ef60
  • 8 commits
  • 24 files changed
  • 0 commit comments
  • 4 contributors
Showing with 496 additions and 33 deletions.
  1. +160 −15 app/assets/javascripts/fakesnladders.js
  2. +14 −5 app/assets/javascripts/gameRequest.js
  3. +256 −0 app/assets/stylesheets/dice.css
  4. +29 −0 app/views/home/_dice.html.erb
  5. +5 −3 app/views/home/index.html.erb
  6. +1 −0  public/assets/application-a2f3da0e82dbdbff2ecd12b2bead6043.css
  7. BIN  public/assets/application-a2f3da0e82dbdbff2ecd12b2bead6043.css.gz
  8. +20 −0 public/assets/application-e85252ec814a11abdf9c2fa86528e1df.js
  9. BIN  public/assets/application-e85252ec814a11abdf9c2fa86528e1df.js.gz
  10. +1 −1  public/assets/application.css
  11. BIN  public/assets/application.css.gz
  12. +5 −5 public/assets/application.js
  13. BIN  public/assets/application.js.gz
  14. BIN  public/assets/face1.png
  15. BIN  public/assets/face2.png
  16. BIN  public/assets/face3.png
  17. BIN  public/assets/face4.png
  18. BIN  public/assets/face5.png
  19. BIN  public/assets/face6.png
  20. +1 −0  public/assets/fakesnladders-3b88c62e8009855d1e4e5d1cc75b1f98.js
  21. BIN  public/assets/fakesnladders-3b88c62e8009855d1e4e5d1cc75b1f98.js.gz
  22. +1 −1  public/assets/fakesnladders.js
  23. BIN  public/assets/fakesnladders.js.gz
  24. +3 −3 public/assets/manifest.yml
View
175 app/assets/javascripts/fakesnladders.js
@@ -1,6 +1,8 @@
+var topic = '#leedshack';
var tickManager;
var TICK_INTERVAL = Math.floor(1000 / 30);
var allowClick = true;
+var SQUARE_SIZE;
function Ladder(fromGrid, toGrid) {
this.fromGrid = fromGrid;
@@ -86,39 +88,65 @@ function Player(game, scoreGrid, image) {
}
Player.prototype.move = function(newScoreGrid) {
- // TODO move horizontally, never diagonally
var this_ = this;
function completion() {
newScoreGrid.doActions(this_);
}
- tickManager.addAnimation(new MoveAnimation(this,
- new Point(newScoreGrid.position.x,
- newScoreGrid.position.y), 0.5), completion);
+ if (this.rect.y == newScoreGrid.position.y) {
+ this.moveStraightLine(newScoreGrid);
+ } else {
+ var grid;
+ var i;
+ for (i = this.scoreGrid.sqNo; i <= newScoreGrid.sqNo; i++) {
+ grid = this.game.getGrid(i);
+ if (grid.rect.y != this.scoreGrid.rect.y) {
+ break;
+ }
+ }
+ var this_ = this;
+ function moveUp() {
+ this_.moveStraightLine(this_.game.getGrid(i), finalMove);
+ }
+ function finalMove() {
+ this_.moveStraightLine(newScoreGrid);
+ }
+ if (i != this.scoreGrid.sqNo) {
+ this.moveStraightLine(this.game.getGrid(i - 1),
+ moveUp);
+ }
+ }
}
-Player.prototype.moveStraightLine = function(newScoreGrid) {
+Player.prototype.moveStraightLine = function(newScoreGrid, myCompletion) {
var this_ = this;
- function completion() {
+ function everythingCompletion() {
newScoreGrid.doActions(this_);
+ this_.scoreGrid = newScoreGrid;
+ }
+ var completion;
+ if (myCompletion != null) {
+ completion = myCompletion;
+ } else {
+ completion = everythingCompletion;
}
tickManager.addAnimation(new MoveAnimation(this,
new Point(newScoreGrid.position.x,
- newScoreGrid.position.y), 0.5), completion);
+ newScoreGrid.position.y), 1), completion);
};
Player.prototype.draw = function(context) {
- context.drawImage(this.image, this.rect.x,
- this.rect.y);
+ context.drawImage(this.image,
+ this.rect.x + SQUARE_SIZE / 2 - this.image.width / 2,
+ this.rect.y + SQUARE_SIZE / 2 - this.image.height / 2);
};
Player.prototype.hit = function(p) {
- this.move(this.game.getGrid(4));
};
-function Grid(sqNo, coordinates, squareSize, squaresToSide) {
+function Grid(sqNo, coordinates, squaresToSide) {
this.sqNo = sqNo;
this.coordinates = coordinates;
- this.squareSize = squareSize;
+ this.squareSize = SQUARE_SIZE;
this.squaresToSide = squaresToSide;
this.position = new Point(this.coordinates.x * this.squareSize,
this.coordinates.y * this.squareSize);
@@ -158,6 +186,8 @@ function FakesNLadders(layer, gridSize) {
this.layer.addGameObject(this);
this.squaresToSide = 10;
this.squareSize = this.gridSize / this.squaresToSide;
+ this.playerMap = {};
+ SQUARE_SIZE = this.squareSize;
}
FakesNLadders.prototype.init = function(redraw) {
@@ -167,13 +197,13 @@ FakesNLadders.prototype.init = function(redraw) {
for (var y = this.squaresToSide - 1; y >= 0; y--) {
for (var x = this.squaresToSide - 1; x >= 0; x--) {
this.grids.push(new Grid(sqNo++, new Point(x, y),
- this.squareSize, this.squaresToSide));
+ this.squaresToSide));
this.layer.addGameObject(this.grids[this.grids.length - 1]);
}
y--;
for (var x = 0; x < this.squaresToSide; x++) {
this.grids.push(new Grid(sqNo++, new Point(x, y),
- this.squareSize, this.squaresToSide));
+ this.squaresToSide));
this.layer.addGameObject(this.grids[this.grids.length - 1]);
}
}
@@ -185,12 +215,71 @@ FakesNLadders.prototype.init = function(redraw) {
this.layer.addGameObject(new Ladder(this.getGrid(55), this.getGrid(86)));
this.layer.addGameObject(new Ladder(this.getGrid(49), this.getGrid(92)));
this.layer.addGameObject(new Ladder(this.getGrid(12), this.getGrid(31)));
+
+ // init players
+ var this_ = this;
+ var request = new GameRequest();
+ request.getAllUsers(function(userList) {
+ if(!userList || !userList.length) {
+ return;
+ }
+
+ for(var i = 0; i < userList.length; i++) {
+ this_.initPlayer(userList[i], redraw);
+ }
+ });
+
+ // start player update loop
+ function playerUpdateLoop() {
+ this_.updatePlayers(redraw);
+ }
+ setInterval(playerUpdateLoop, 2000);
+}
+FakesNLadders.prototype.initPlayer = function(userInfo, redraw) {
var playerImage = new Image();
- playerImage.src = testPlayerImage;
+ playerImage.src = userInfo.avatar_url;
+ playerImage.width = 40;
+ playerImage.height = 40;
playerImage.onload = redraw;
+
+ this.playerMap[userInfo.id] = new Player(this, this.getGrid(userInfo.position), playerImage);
+ this.layer.addGameObject(this.playerMap[userInfo.id]);
+
var p = new Player(this, this.getGrid(0), playerImage);
this.layer.addGameObject(p);
+
+ var this_ = this;
+ document.getElementById('option-a').onclick = function() {
+ this_.makeChoice('a');
+ };
+ document.getElementById('option-b').onclick = function() {
+ this_.makeChoice('b');
+ };
+
+ this.nextChoice();
+}
+
+FakesNLadders.prototype.updatePlayers = function(redraw) {
+ var this_ = this;
+ var request = new GameRequest();
+ request.getAllUsers(function(userList) {
+ if(!userList || !userList.length) {
+ return;
+ }
+
+ for(var i = 0; i < userList.length; i++) {
+ var playerId = userList[i].id;
+ var player = this.playerMap[playerId];
+
+ if(player) {
+ var newSquare = userList[i].position;
+ player.move(this.getGrid(newSquare));
+ } else {
+ this_.initPlayer(userList[i], redraw);
+ }
+ }
+ });
}
FakesNLadders.prototype.getGrid = function(score) {
@@ -223,6 +312,62 @@ FakesNLadders.prototype.draw = function(context) {
FakesNLadders.prototype.hit = function(p) {
}
+function diceMove(face) {
+ var x,y,z;
+ switch (face) {
+ case 6:
+ x = 0; y = 0; z = 0;
+ break;
+ case 5:
+ x = 90; y = 0; z = 0;
+ break;
+ case 4:
+ x = 90; y = 0; z = 90;
+ break;
+ case 3:
+ x = 180; y = 0; z = 90;
+ break;
+ case 2:
+ x = 180; y = 90; z = 90;
+ break;
+ case 1:
+ x = 180; y = 90; z = 180;
+ break;
+ }
+ document.getElementById('cube').style.webkitTransform = "rotateX("+x+"deg) rotateY("+y+"deg) rotateZ("+z+"deg)";
+ document.getElementById('cube').style.MozTransform = "rotateX("+x+"deg) rotateY("+y+"deg) rotateZ("+z+"deg)";
+ document.getElementById('cube').style.msTransform = "rotateX("+x+"deg) rotateY("+y+"deg) rotateZ("+z+"deg)";
+}
+
+function htmlescape(s) {
+ return s.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;');
+}
+
+FakesNLadders.prototype.nextChoice = function() {
+ console.log('fetching next choice...');
+ var this_ = this;
+ new GameRequest().getNewChoice(topic, function(choice_id, option_a, option_b) {
+ console.log('next choice received:');
+ console.log('choice_id: ' + choice_id);
+ console.log('option_a: ' + option_a);
+ console.log('option_b: ' + option_b);
+ this_.cur_choice_id = choice_id;
+ document.getElementById('option-a').innerHTML = 'Option A<br /><br />' + htmlescape(option_a);
+ document.getElementById('option-b').innerHTML = 'Option B<br /><br />' + htmlescape(option_b);
+ });
+}
+
+FakesNLadders.prototype.makeChoice = function(choice) {
+ console.log('choice: ' + choice + ' with choice_id ' + this.cur_choice_id);
+ document.getElementById('option-a').innerHTML = 'Option A';
+ document.getElementById('option-b').innerHTML = 'Option B';
+ var this_ = this;
+ new GameRequest().checkChoice(this.cur_choice_id, choice, function(correct) {
+ console.log('correct: ' + correct);
+ this_.nextChoice();
+ });
+}
+
function init() {
var game = document.getElementById('game');
var gameContext = game.getContext('2d');
View
19 app/assets/javascripts/gameRequest.js
@@ -32,22 +32,31 @@ GameRequest.prototype.updateUserSquare = function(userId, newSquare, optionalCal
// callback will be passed the question id, option a, and option b
GameRequest.prototype.getNewChoice = function(topic, callback) {
- var url = "/api/choices/new";
+ var url = "/api/choices/new?topic=" + escape(topic);
var reqCallback = function(response) {
- callback(response.id, response.option_a, response.option_b);
+ callback(response.id, response.a, response.b);
};
- this.sendRequest("GET", url, {"topic": topic}, reqCallback);
+ this.sendRequest("GET", url, null, reqCallback);
}
// callback will be passed true if question was answered correctly, else false
// choice parameter should be 'a' or 'b'
GameRequest.prototype.checkChoice = function(questionId, choice, callback) {
var url = "/api/choices/"+questionId;
+ console.log('questionId: ' + questionId);
+ console.log('url: ' + url);
+ console.log('choice: ' + choice);
var reqCallback = function(response) {
+ console.log('checkChoice reqCallback:');
+ console.log(response);
var correct = (response.answer === "real");
callback(correct);
};
- this.sendRequest("PUT", url, {"option": choice}, reqCallback);
+ $.ajax(url, {
+ type: 'PUT',
+ dataType: 'json',
+ data: {"option": choice}
+ }).done(reqCallback);
}
// callback will take a single request respose object
@@ -61,7 +70,7 @@ GameRequest.prototype.sendRequest = function(method, url, sendObject, callback)
eval("var resp = " + req.response); // ick
callback(resp);
} else {
- alert("Error: ready but status was " + req.statusText);
+ console.log("Error: ready but status was " + req.statusText);
}
}
};
View
256 app/assets/stylesheets/dice.css
@@ -0,0 +1,256 @@
+input[type='range'] {
+ -webkit-appearance: none;
+ background-color: #fff;
+ margin:5px;
+ border-radius: 30px;
+ height: 30px;
+ width: 200px;
+ min-width: 200px;
+ max-width: 200px;
+ box-shadow: 0px 2px 5px rgba(0,0,0,0.8) inset,
+ 0px 15px 0px rgba(0,0,0,0.05) inset;
+ border: 1px #ccc solid;
+ text-align:center;
+ font-size:20px;
+ font-family: 'Marker Felt', "Comic Sans MS",fantasy;
+ text-transform:lowercase;
+ line-height:30px;
+}
+
+input[type='range']::-webkit-slider-thumb {
+ -webkit-appearance: none;
+ background: -webkit-linear-gradient(top, #aeaeae 0%,#efefef 100%); /* Chrome10+,Safari5.1+ */
+ width: 28px;
+ height: 28px;
+ margin:1px;
+ border-radius: 30px;
+ box-shadow: 0 1px 2px rgba(255,255,255,0.9),
+ 1px 1px 2px rgba(0,0,0,0.3);
+ border: 1px #bbb solid;
+}
+
+#area {
+ -webkit-perspective: 1000px;
+ -moz-perspective: 1000px;
+ -ms-perspective: 1000px;
+ -webkit-perspective-origin: 50% 50%;
+ -moz-perspective-origin: 50% 50%;
+ -ms-perspective-origin: 50% 50%;
+ position:relative;
+ top:0px;
+ left:30px;
+ height: 100px;
+ width:100px;
+
+}
+#cube {
+ position:absolute;
+ top:0px;
+ left:0px;
+ height:100px;
+ width:100px;
+ -webkit-transform-style: preserve-3d;
+ -moz-transform-style: preserve-3d;
+ -ms-transform-style: preserve-3d;
+ -webkit-animation: none;
+ -moz-animation: none;
+ -ms-animation: none;
+ -webkit-transition: -webkit-transform 250ms linear;
+ -moz-transition: -moz-transform 250ms linear;
+ -ms-transition: -ms-transform 250ms linear;
+ -webkit-transform-origin: 50% 50%;
+ -moz-transform-origin: 50% 50%;
+ -ms-transform-origin: 50% 50%;
+}
+
+.side{
+ height:90px;
+ width:90px;
+ border:5px rgba(215,215,215,1) solid;
+ color:#000;
+ line-height:90px;
+ text-align:center;
+ font-size:35px;
+ font-family: 'Marker Felt', "Comic Sans MS",fantasy;
+ text-transform:lowercase;
+ text-shadow:
+ 1px 0px #fff,
+ 0px 1px #fff,
+ 0px -1px #fff,
+ -1px 0px #fff,
+ -1px 1px #fff,
+ -1px -1px #fff,
+ 1px 1px #fff;
+ position:absolute;
+ border-radius:30px;
+ background-color: rgba(215,215,215,1) ;
+ -webkit-transform-origin: 50% 50%;
+ -moz-transform-origin: 50% 50%;
+ -ms-transform-origin: 50% 50%;
+
+
+}
+.corners.left{
+ -webkit-transform-style: preserve-3d;
+ -moz-transform-style: preserve-3d;
+ -ms-transform-style: preserve-3d;
+ position:absolute;
+ top:0;
+ left:0px;
+ -webkit-transform:translateX(0px) ;
+ -moz-transform:translateX(0px) ;
+ -ms-transform:translateX(0px) ;
+}
+.corners.right{
+ -webkit-transform-style: preserve-3d;
+ -moz-transform-style: preserve-3d;
+ -ms-transform-style: preserve-3d;
+ position:absolute;
+ top:0;
+ left:0px;
+ -webkit-transform:translateX(100px) rotateY(180deg);
+ -moz-transform:translateX(100px) rotateY(180deg);
+ -ms-transform:translateX(100px) rotateY(180deg);
+}
+.cornerwrapper{
+ -webkit-transform-style: preserve-3d;
+ -moz-transform-style: preserve-3d;
+ -ms-transform-style: preserve-3d;
+ position:absolute;
+ top:0;
+ left:0;
+ height:35px;
+ width:35px;
+}
+.cornerwrapper.ftl{
+ -webkit-transform:rotateX(315deg) rotateZ(10deg) translateZ(-22px) translateY(-31px) translateX(-14px);
+ -moz-transform:rotateX(315deg) rotateZ(10deg) translateZ(-22px) translateY(-31px) translateX(-14px);
+ -ms-transform:rotateX(315deg) rotateZ(10deg) translateZ(-22px) translateY(-31px) translateX(-14px);
+}
+.cornerwrapper.fbl{
+ -webkit-transform:rotateX(225deg) rotateZ(10deg) translateZ(-22px) translateY(-76px) translateX(-22px);
+ -moz-transform:rotateX(225deg) rotateZ(10deg) translateZ(-22px) translateY(-76px) translateX(-22px);
+ -ms-transform:rotateX(225deg) rotateZ(10deg) translateZ(-22px) translateY(-76px) translateX(-22px);
+}
+.cornerwrapper.btr{
+ -webkit-transform:rotateX(45deg) rotateZ(10deg) translateZ(-68px) translateY(-31px) translateX(-14px);
+ -moz-transform:rotateX(45deg) rotateZ(10deg) translateZ(-68px) translateY(-31px) translateX(-14px);
+ -ms-transform:rotateX(45deg) rotateZ(10deg) translateZ(-68px) translateY(-31px) translateX(-14px);
+}
+.cornerwrapper.bbr{
+ -webkit-transform:rotateX(135deg) rotateZ(10deg) translateZ(-68px) translateY(-76px) translateX(-22px);
+ -moz-transform:rotateX(135deg) rotateZ(10deg) translateZ(-68px) translateY(-76px) translateX(-22px);
+ -ms-transform:rotateX(135deg) rotateZ(10deg) translateZ(-68px) translateY(-76px) translateX(-22px);
+}
+
+ .corner{
+ background-color:transparent;
+ height:0px;
+ width:0px;
+ border-left: 35px rgba(215,215,215,1) solid;
+ border-top: 20px transparent solid;
+ border-bottom: 20px transparent solid;
+ -webkit-transform:translateZ(25px) translateX(-0px) rotateZ(0deg) rotateX(90deg) rotateY(-45deg) ;
+ -moz-transform:translateZ(25px) translateX(-0px) rotateZ(0deg) rotateX(90deg) rotateY(-45deg) ;
+ -ms-transform:translateZ(25px) translateX(-0px) rotateZ(0deg) rotateX(90deg) rotateY(-45deg) ;
+ -webkit-transform-origin: 100% 0%;
+ -moz-transform-origin: 100% 0%;
+ -ms-transform-origin: 100% 0%;
+}
+
+.side.front{
+ -webkit-transform:rotateY(0deg) translateZ(50px);
+ -moz-transform:rotateY(0deg) translateZ(50px);
+ -ms-transform:rotateY(0deg) translateZ(50px);
+ background: rgba(255,0,0,0.5) ;
+ z-index:1;
+ border:5px rgba(255,255,255,1) solid;
+ -webkit-backface-visibility: hidden;
+}
+.front2{
+ -webkit-transform:rotateY(0deg) translateZ(49.9px);
+ -moz-transform:rotateY(0deg) translateZ(49.9px);
+ -ms-transform:rotateY(0deg) translateZ(49.9px);
+ z-index:0;
+}
+
+.side.back{
+ -webkit-transform:rotateY(180deg) rotateZ(-90deg) translateZ(50px) ;
+ -moz-transform:rotateY(180deg) rotateZ(-90deg) translateZ(50px) ;
+ -ms-transform:rotateY(180deg) rotateZ(-90deg) translateZ(50px) ;
+ background: rgba(255,255,0,0.5);
+ z-index:1;
+ border:5px rgba(255,255,255,1) solid;
+ -webkit-backface-visibility: hidden;
+}
+.back2{
+ -webkit-transform:rotateY(180deg) translateZ(49.9px) ;
+ -moz-transform:rotateY(180deg) translateZ(49.9px) ;
+ -ms-transform:rotateY(180deg) translateZ(49.9px) ;
+ z-index:0;
+}
+
+.side.bottom{
+ -webkit-transform:rotateX(-90deg) translateZ(50px);
+ -moz-transform:rotateX(-90deg) translateZ(50px);
+ -ms-transform:rotateX(-90deg) translateZ(50px);
+ background: rgba(0,255,0,0.5);
+ z-index:1;
+ border:5px rgba(255,255,255,1) solid;
+ -webkit-backface-visibility: hidden;
+}
+.bottom2{
+ -webkit-transform:rotateX(-90deg) translateZ(49.9px);
+ -moz-transform:rotateX(-90deg) translateZ(49.9px);
+ -ms-transform:rotateX(-90deg) translateZ(49.9px);
+ z-index:0;
+}
+
+.side.top{
+ -webkit-transform:rotateX(90deg) rotateZ(90deg) translateZ(50px) ;
+ -moz-transform:rotateX(90deg) rotateZ(90deg) translateZ(50px) ;
+ -ms-transform:rotateX(90deg) rotateZ(90deg) translateZ(50px) ;
+ background: rgba(0,255,255,0.5);
+ z-index:1;
+ border:5px rgba(255,255,255,1) solid;
+ -webkit-backface-visibility: hidden;
+}
+.top2{
+ -webkit-transform:rotateX(90deg) translateZ(49.9px) ;
+ -moz-transform:rotateX(90deg) translateZ(49.9px) ;
+ -ms-transform:rotateX(90deg) translateZ(49.9px) ;
+ z-index:0;
+}
+
+.side.right{
+ -webkit-transform:rotateY(90deg) rotateZ(-90deg) translateZ(50px) ;
+ -moz-transform:rotateY(90deg) rotateZ(-90deg) translateZ(50px) ;
+ -ms-transform:rotateY(90deg) rotateZ(-90deg) translateZ(50px) ;
+ background: rgba(0,0,255,0.5);
+ z-index:1;
+ border:5px rgba(255,255,255,1) solid;
+ -webkit-backface-visibility: hidden;
+}
+.right2{
+ -webkit-transform:rotateY(90deg) translateZ(49.9px) ;
+ -moz-transform:rotateY(90deg) translateZ(49.9px) ;
+ -ms-transform:rotateY(90deg) translateZ(49.9px) ;
+ z-index:0;
+}
+
+.side.left{
+ -webkit-transform:rotateY(-90deg) translateZ(50px);
+ -moz-transform:rotateY(-90deg) translateZ(50px);
+ -ms-transform:rotateY(-90deg) translateZ(50px);
+ background: rgba(255,0,255,0.5);
+ z-index:1;
+ border:5px rgba(255,255,255,1) solid;
+ -webkit-backface-visibility: hidden;
+}
+.left2{
+ -webkit-transform:rotateY(-90deg) translateZ(49.9px);
+ -moz-transform:rotateY(-90deg) translateZ(49.9px);
+ -ms-transform:rotateY(-90deg) translateZ(49.9px);
+ z-index:0;
+}
+
View
29 app/views/home/_dice.html.erb
@@ -0,0 +1,29 @@
+<div id="area">
+ <div id="cube">
+ <div class="side front2"></div>
+ <div class="side front"><%= image_tag 'face6.png' %></div>
+ <div class="side back2"></div>
+ <div class="side back"><%= image_tag 'face3.png' %></div>
+ <div class="side bottom2"></div>
+ <div class="side bottom"><%= image_tag 'face5.png' %></div>
+ <div class="side top2"></div>
+ <div class="side top"><%= image_tag 'face2.png' %></div>
+ <div class="side right2"></div>
+ <div class="side right"><%= image_tag 'face4.png' %></div>
+ <div class="side left2"></div>
+ <div class="side left"><%= image_tag 'face1.png' %></div>
+ <div class="corners left">
+ <div class="cornerwrapper ftl"><div class="corner"></div></div>
+ <div class="cornerwrapper btr"><div class="corner"></div></div>
+ <div class="cornerwrapper fbl"><div class="corner"></div></div>
+ <div class="cornerwrapper bbr"><div class="corner"></div></div>
+ </div>
+ <div class="corners right">
+ <div class="cornerwrapper ftl"><div class="corner"></div></div>
+ <div class="cornerwrapper btr"><div class="corner"></div></div>
+ <div class="cornerwrapper fbl"><div class="corner"></div></div>
+ <div class="cornerwrapper bbr"><div class="corner"></div></div>
+ </div>
+ </div>
+ </div>
+
View
8 app/views/home/index.html.erb
@@ -47,9 +47,11 @@
<canvas id="back-buffer" width="600" height="600"></canvas>
<div id="side">
<div style="width: 329px; height: 120px; font-size: 16px; font-family: sans-serif; font-weight: bold; border: 0.5px solid black; border-left: 0px; border-top: 0px;">100</div>
- <div class="button">Option A etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc</div>
- <div class="button">Option B etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc</div>
- <div style="width: 329px; height: 120px; font-size: 16px; font-family: sans-serif; font-weight: bold;">STATUS</div>
+ <div id="option-a" class="button">Option A</div>
+ <div id="option-b" class="button">Option B</div>
+ <div style="width: 329px; height: 120px; font-size: 16px; font-family: sans-serif; font-weight: bold;">
+ <%= render :partial => 'dice' %>
+ </div>
</div>
</div>
View
1  public/assets/application-a2f3da0e82dbdbff2ecd12b2bead6043.css
1 addition, 0 deletions not shown
View
BIN  public/assets/application-a2f3da0e82dbdbff2ecd12b2bead6043.css.gz
Binary file not shown
View
20 public/assets/application-e85252ec814a11abdf9c2fa86528e1df.js
20 additions, 0 deletions not shown
View
BIN  public/assets/application-e85252ec814a11abdf9c2fa86528e1df.js.gz
Binary file not shown
View
2  public/assets/application.css
1 addition, 1 deletion not shown
View
BIN  public/assets/application.css.gz
Binary file not shown
View
10 public/assets/application.js
5 additions, 5 deletions not shown
View
BIN  public/assets/application.js.gz
Binary file not shown
View
BIN  public/assets/face1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  public/assets/face2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  public/assets/face3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  public/assets/face4.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  public/assets/face5.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  public/assets/face6.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
1  public/assets/fakesnladders-3b88c62e8009855d1e4e5d1cc75b1f98.js
@@ -0,0 +1 @@
+function Ladder(e,t){this.fromGrid=e,this.toGrid=t,this.ladderWidth=24,this.ladderStep=16,this.lineWidth=4,this.color="rgb(153, 51, 0)",this.fromGrid.registerAction(this.action())}function Player(e,t,n){this.game=e,this.scoreGrid=t,this.image=n,this.rect=this.scoreGrid.rect}function Grid(e,t,n,r){this.sqNo=e,this.coordinates=t,this.squareSize=n,this.squaresToSide=r,this.position=new Point(this.coordinates.x*this.squareSize,this.coordinates.y*this.squareSize),this.rect=new Rect(this.position.x,this.position.y,this.squareSize,this.squareSize),this.actions=[]}function FakesNLadders(e,t){this.gridSize=t,this.layer=e,this.layer.addGameObject(this),this.squaresToSide=10,this.squareSize=this.gridSize/this.squaresToSide}function diceMove(e){var t,n,r;switch(e){case 6:t=0,n=0,r=0;break;case 5:t=90,n=0,r=0;break;case 4:t=90,n=0,r=90;break;case 3:t=180,n=0,r=90;break;case 2:t=180,n=90,r=90;break;case 1:t=180,n=90,r=180}document.getElementById("cube").style.webkitTransform="rotateX("+t+"deg) rotateY("+n+"deg) rotateZ("+r+"deg)",document.getElementById("cube").style.MozTransform="rotateX("+t+"deg) rotateY("+n+"deg) rotateZ("+r+"deg)",document.getElementById("cube").style.msTransform="rotateX("+t+"deg) rotateY("+n+"deg) rotateZ("+r+"deg)"}function init(){function o(){r.drawImage(i,0,0),r.save(),s.draw(r),r.restore(),t.drawImage(n,0,0)}var e=document.getElementById("game"),t=e.getContext("2d"),n=document.getElementById("back-buffer"),r=n.getContext("2d"),i=document.getElementById("background"),s=new Layer;tickManager=new TickManager(o),document.addEventListener("mousedown",function(t){t.stopPropagation();var n=new Point(t.pageX-e.offsetLeft,t.pageY-e.offsetTop);s.hit(n),o()},!1);var u=new FakesNLadders(s,HEIGHT);u.init(o),o()}var tickManager,TICK_INTERVAL=Math.floor(1e3/30),allowClick=!0;Ladder.prototype.action=function(){function t(t){t.moveStraightLine(e.toGrid)}var e=this;return t},Ladder.prototype.drawLadder=function(e,t,n){e.beginPath();var r=t;e.moveTo(r.x+r.width/2-this.ladderWidth/2,r.y+r.height/2),r=n,e.lineTo(r.x+r.width/2-this.ladderWidth/2,r.y+r.height/2),r=t,e.moveTo(r.x+r.width/2+this.ladderWidth/2,r.y+r.height/2),r=n,e.lineTo(r.x+r.width/2+this.ladderWidth/2,r.y+r.height/2);var i=n.x-t.x,s=n.y-t.y,o=Math.sqrt(i*i+s*s),u=this.ladderStep/o,a=(n.x-t.x)*u,f=(n.y-t.y)*u,l=r.x+r.width/2-this.ladderWidth/2,c=r.y+r.height/2,h;for(h=0;h<o-this.ladderStep*2;h+=this.ladderStep)l-=a,c-=f,e.moveTo(l,c),e.lineTo(l+this.ladderWidth,c);e.stroke()},Ladder.prototype.draw=function(e){e.save(),e.lineWidth=this.lineWidth,e.strokeStyle="rgb(70, 70, 70)",this.drawLadder(e,new Rect(this.fromGrid.rect.x,this.fromGrid.rect.y+3,this.fromGrid.rect.width,this.fromGrid.rect.height),new Rect(this.toGrid.rect.x,this.toGrid.rect.y+3,this.toGrid.rect.width,this.toGrid.rect.height)),e.strokeStyle=this.color,this.drawLadder(e,this.fromGrid.rect,this.toGrid.rect),e.restore()},Ladder.prototype.hit=function(e){},Player.prototype.move=function(e){function n(){e.doActions(t)}var t=this;tickManager.addAnimation(new MoveAnimation(this,new Point(e.position.x,e.position.y),.5),n)},Player.prototype.moveStraightLine=function(e){function n(){e.doActions(t)}var t=this;tickManager.addAnimation(new MoveAnimation(this,new Point(e.position.x,e.position.y),.5),n)},Player.prototype.draw=function(e){e.drawImage(this.image,this.rect.x,this.rect.y)},Player.prototype.hit=function(e){this.move(this.game.getGrid(4))},Grid.prototype.draw=function(e){e.save(),e.font="bold 16px sans-serif",e.textBaseline="top",e.textAlign="middle",e.fillText(this.sqNo.toString(),this.position.x+3,this.position.y+3),e.restore()},Grid.prototype.hit=function(e){},Grid.prototype.registerAction=function(e){this.actions.push(e)},Grid.prototype.doActions=function(e){for(var t=0;t<this.actions.length;t++)this.actions[t](e)},FakesNLadders.prototype.init=function(e){var t=0;this.grids=[];for(var n=this.squaresToSide-1;n>=0;n--){for(var r=this.squaresToSide-1;r>=0;r--)this.grids.push(new Grid(t++,new Point(r,n),this.squareSize,this.squaresToSide)),this.layer.addGameObject(this.grids[this.grids.length-1]);n--;for(var r=0;r<this.squaresToSide;r++)this.grids.push(new Grid(t++,new Point(r,n),this.squareSize,this.squaresToSide)),this.layer.addGameObject(this.grids[this.grids.length-1])}this.layer.addGameObject(new Ladder(this.getGrid(3),this.getGrid(22))),this.layer.addGameObject(new Ladder(this.getGrid(25),this.getGrid(43))),this.layer.addGameObject(new Ladder(this.getGrid(40),this.getGrid(58))),this.layer.addGameObject(new Ladder(this.getGrid(81),this.getGrid(99))),this.layer.addGameObject(new Ladder(this.getGrid(55),this.getGrid(86))),this.layer.addGameObject(new Ladder(this.getGrid(49),this.getGrid(92))),this.layer.addGameObject(new Ladder(this.getGrid(12),this.getGrid(31)));var i=new Image;i.src=testPlayerImage,i.onload=e;var s=new Player(this,this.getGrid(0),i);this.layer.addGameObject(s)},FakesNLadders.prototype.getGrid=function(e){return this.grids[e]},FakesNLadders.prototype.draw=function(e){e.save(),e.fillStyle="black",e.strokeRect(0,0,this.gridSize,this.gridSize),e.beginPath();for(var t=.5;t<this.gridSize;t+=this.squareSize)e.moveTo(t,0),e.lineTo(t,this.gridSize);for(var n=.5;n<this.gridSize;n+=this.squareSize)e.moveTo(0,n),e.lineTo(this.gridSize,n);e.strokeStyle="rgba(70, 70, 70, 1)",e.lineWidth=1,e.stroke(),e.restore()},FakesNLadders.prototype.hit=function(e){},window.onload=init;
View
BIN  public/assets/fakesnladders-3b88c62e8009855d1e4e5d1cc75b1f98.js.gz
Binary file not shown
View
2  public/assets/fakesnladders.js
@@ -1 +1 @@
-function Ladder(e,t){this.fromGrid=e,this.toGrid=t,this.ladderWidth=24,this.ladderStep=16,this.lineWidth=4,this.color="rgb(153, 51, 0)",this.fromGrid.registerAction(this.action())}function Player(e,t,n){this.game=e,this.scoreGrid=t,this.image=n,this.rect=this.scoreGrid.rect}function Grid(e,t,n,r){this.sqNo=e,this.coordinates=t,this.squareSize=n,this.squaresToSide=r,this.position=new Point(this.coordinates.x*this.squareSize,this.coordinates.y*this.squareSize),this.rect=new Rect(this.position.x,this.position.y,this.squareSize,this.squareSize),this.actions=[]}function FakesNLadders(e,t){this.gridSize=t,this.layer=e,this.layer.addGameObject(this),this.squaresToSide=10,this.squareSize=this.gridSize/this.squaresToSide}function init(){function o(){r.drawImage(i,0,0),r.save(),s.draw(r),r.restore(),t.drawImage(n,0,0)}var e=document.getElementById("game"),t=e.getContext("2d"),n=document.getElementById("back-buffer"),r=n.getContext("2d"),i=document.getElementById("background"),s=new Layer;tickManager=new TickManager(o),document.addEventListener("mousedown",function(t){t.stopPropagation();var n=new Point(t.pageX-e.offsetLeft,t.pageY-e.offsetTop);s.hit(n),o()},!1);var u=new FakesNLadders(s,HEIGHT);u.init(o),o()}var tickManager,TICK_INTERVAL=Math.floor(1e3/30),allowClick=!0;Ladder.prototype.action=function(){function t(t){t.moveStraightLine(e.toGrid)}var e=this;return t},Ladder.prototype.drawLadder=function(e,t,n){e.beginPath();var r=t;e.moveTo(r.x+r.width/2-this.ladderWidth/2,r.y+r.height/2),r=n,e.lineTo(r.x+r.width/2-this.ladderWidth/2,r.y+r.height/2),r=t,e.moveTo(r.x+r.width/2+this.ladderWidth/2,r.y+r.height/2),r=n,e.lineTo(r.x+r.width/2+this.ladderWidth/2,r.y+r.height/2);var i=n.x-t.x,s=n.y-t.y,o=Math.sqrt(i*i+s*s),u=this.ladderStep/o,a=(n.x-t.x)*u,f=(n.y-t.y)*u,l=r.x+r.width/2-this.ladderWidth/2,c=r.y+r.height/2,h;for(h=0;h<o-this.ladderStep*2;h+=this.ladderStep)l-=a,c-=f,e.moveTo(l,c),e.lineTo(l+this.ladderWidth,c);e.stroke()},Ladder.prototype.draw=function(e){e.save(),e.lineWidth=this.lineWidth,e.strokeStyle="rgb(70, 70, 70)",this.drawLadder(e,new Rect(this.fromGrid.rect.x,this.fromGrid.rect.y+3,this.fromGrid.rect.width,this.fromGrid.rect.height),new Rect(this.toGrid.rect.x,this.toGrid.rect.y+3,this.toGrid.rect.width,this.toGrid.rect.height)),e.strokeStyle=this.color,this.drawLadder(e,this.fromGrid.rect,this.toGrid.rect),e.restore()},Ladder.prototype.hit=function(e){},Player.prototype.move=function(e){function n(){e.doActions(t)}var t=this;tickManager.addAnimation(new MoveAnimation(this,new Point(e.position.x,e.position.y),.5),n)},Player.prototype.moveStraightLine=function(e){function n(){e.doActions(t)}var t=this;tickManager.addAnimation(new MoveAnimation(this,new Point(e.position.x,e.position.y),.5),n)},Player.prototype.draw=function(e){e.drawImage(this.image,this.rect.x,this.rect.y)},Player.prototype.hit=function(e){this.move(this.game.getGrid(4))},Grid.prototype.draw=function(e){e.save(),e.font="bold 16px sans-serif",e.textBaseline="top",e.textAlign="middle",e.fillText(this.sqNo.toString(),this.position.x+3,this.position.y+3),e.restore()},Grid.prototype.hit=function(e){},Grid.prototype.registerAction=function(e){this.actions.push(e)},Grid.prototype.doActions=function(e){for(var t=0;t<this.actions.length;t++)this.actions[t](e)},FakesNLadders.prototype.init=function(e){var t=0;this.grids=[];for(var n=this.squaresToSide-1;n>=0;n--){for(var r=this.squaresToSide-1;r>=0;r--)this.grids.push(new Grid(t++,new Point(r,n),this.squareSize,this.squaresToSide)),this.layer.addGameObject(this.grids[this.grids.length-1]);n--;for(var r=0;r<this.squaresToSide;r++)this.grids.push(new Grid(t++,new Point(r,n),this.squareSize,this.squaresToSide)),this.layer.addGameObject(this.grids[this.grids.length-1])}this.layer.addGameObject(new Ladder(this.getGrid(3),this.getGrid(22))),this.layer.addGameObject(new Ladder(this.getGrid(25),this.getGrid(43))),this.layer.addGameObject(new Ladder(this.getGrid(40),this.getGrid(58))),this.layer.addGameObject(new Ladder(this.getGrid(81),this.getGrid(99))),this.layer.addGameObject(new Ladder(this.getGrid(55),this.getGrid(86))),this.layer.addGameObject(new Ladder(this.getGrid(49),this.getGrid(92))),this.layer.addGameObject(new Ladder(this.getGrid(12),this.getGrid(31)));var i=new Image;i.src=testPlayerImage,i.onload=e;var s=new Player(this,this.getGrid(0),i);this.layer.addGameObject(s)},FakesNLadders.prototype.getGrid=function(e){return this.grids[e]},FakesNLadders.prototype.draw=function(e){e.save(),e.fillStyle="black",e.strokeRect(0,0,this.gridSize,this.gridSize),e.beginPath();for(var t=.5;t<this.gridSize;t+=this.squareSize)e.moveTo(t,0),e.lineTo(t,this.gridSize);for(var n=.5;n<this.gridSize;n+=this.squareSize)e.moveTo(0,n),e.lineTo(this.gridSize,n);e.strokeStyle="rgba(70, 70, 70, 1)",e.lineWidth=1,e.stroke(),e.restore()},FakesNLadders.prototype.hit=function(e){},window.onload=init;
+function Ladder(e,t){this.fromGrid=e,this.toGrid=t,this.ladderWidth=24,this.ladderStep=16,this.lineWidth=4,this.color="rgb(153, 51, 0)",this.fromGrid.registerAction(this.action())}function Player(e,t,n){this.game=e,this.scoreGrid=t,this.image=n,this.rect=this.scoreGrid.rect}function Grid(e,t,n,r){this.sqNo=e,this.coordinates=t,this.squareSize=n,this.squaresToSide=r,this.position=new Point(this.coordinates.x*this.squareSize,this.coordinates.y*this.squareSize),this.rect=new Rect(this.position.x,this.position.y,this.squareSize,this.squareSize),this.actions=[]}function FakesNLadders(e,t){this.gridSize=t,this.layer=e,this.layer.addGameObject(this),this.squaresToSide=10,this.squareSize=this.gridSize/this.squaresToSide}function diceMove(e){var t,n,r;switch(e){case 6:t=0,n=0,r=0;break;case 5:t=90,n=0,r=0;break;case 4:t=90,n=0,r=90;break;case 3:t=180,n=0,r=90;break;case 2:t=180,n=90,r=90;break;case 1:t=180,n=90,r=180}document.getElementById("cube").style.webkitTransform="rotateX("+t+"deg) rotateY("+n+"deg) rotateZ("+r+"deg)",document.getElementById("cube").style.MozTransform="rotateX("+t+"deg) rotateY("+n+"deg) rotateZ("+r+"deg)",document.getElementById("cube").style.msTransform="rotateX("+t+"deg) rotateY("+n+"deg) rotateZ("+r+"deg)"}function init(){function o(){r.drawImage(i,0,0),r.save(),s.draw(r),r.restore(),t.drawImage(n,0,0)}var e=document.getElementById("game"),t=e.getContext("2d"),n=document.getElementById("back-buffer"),r=n.getContext("2d"),i=document.getElementById("background"),s=new Layer;tickManager=new TickManager(o),document.addEventListener("mousedown",function(t){t.stopPropagation();var n=new Point(t.pageX-e.offsetLeft,t.pageY-e.offsetTop);s.hit(n),o()},!1);var u=new FakesNLadders(s,HEIGHT);u.init(o),o()}var tickManager,TICK_INTERVAL=Math.floor(1e3/30),allowClick=!0;Ladder.prototype.action=function(){function t(t){t.moveStraightLine(e.toGrid)}var e=this;return t},Ladder.prototype.drawLadder=function(e,t,n){e.beginPath();var r=t;e.moveTo(r.x+r.width/2-this.ladderWidth/2,r.y+r.height/2),r=n,e.lineTo(r.x+r.width/2-this.ladderWidth/2,r.y+r.height/2),r=t,e.moveTo(r.x+r.width/2+this.ladderWidth/2,r.y+r.height/2),r=n,e.lineTo(r.x+r.width/2+this.ladderWidth/2,r.y+r.height/2);var i=n.x-t.x,s=n.y-t.y,o=Math.sqrt(i*i+s*s),u=this.ladderStep/o,a=(n.x-t.x)*u,f=(n.y-t.y)*u,l=r.x+r.width/2-this.ladderWidth/2,c=r.y+r.height/2,h;for(h=0;h<o-this.ladderStep*2;h+=this.ladderStep)l-=a,c-=f,e.moveTo(l,c),e.lineTo(l+this.ladderWidth,c);e.stroke()},Ladder.prototype.draw=function(e){e.save(),e.lineWidth=this.lineWidth,e.strokeStyle="rgb(70, 70, 70)",this.drawLadder(e,new Rect(this.fromGrid.rect.x,this.fromGrid.rect.y+3,this.fromGrid.rect.width,this.fromGrid.rect.height),new Rect(this.toGrid.rect.x,this.toGrid.rect.y+3,this.toGrid.rect.width,this.toGrid.rect.height)),e.strokeStyle=this.color,this.drawLadder(e,this.fromGrid.rect,this.toGrid.rect),e.restore()},Ladder.prototype.hit=function(e){},Player.prototype.move=function(e){function n(){e.doActions(t)}var t=this;tickManager.addAnimation(new MoveAnimation(this,new Point(e.position.x,e.position.y),.5),n)},Player.prototype.moveStraightLine=function(e){function n(){e.doActions(t)}var t=this;tickManager.addAnimation(new MoveAnimation(this,new Point(e.position.x,e.position.y),.5),n)},Player.prototype.draw=function(e){e.drawImage(this.image,this.rect.x,this.rect.y)},Player.prototype.hit=function(e){this.move(this.game.getGrid(4))},Grid.prototype.draw=function(e){e.save(),e.font="bold 16px sans-serif",e.textBaseline="top",e.textAlign="middle",e.fillText(this.sqNo.toString(),this.position.x+3,this.position.y+3),e.restore()},Grid.prototype.hit=function(e){},Grid.prototype.registerAction=function(e){this.actions.push(e)},Grid.prototype.doActions=function(e){for(var t=0;t<this.actions.length;t++)this.actions[t](e)},FakesNLadders.prototype.init=function(e){var t=0;this.grids=[];for(var n=this.squaresToSide-1;n>=0;n--){for(var r=this.squaresToSide-1;r>=0;r--)this.grids.push(new Grid(t++,new Point(r,n),this.squareSize,this.squaresToSide)),this.layer.addGameObject(this.grids[this.grids.length-1]);n--;for(var r=0;r<this.squaresToSide;r++)this.grids.push(new Grid(t++,new Point(r,n),this.squareSize,this.squaresToSide)),this.layer.addGameObject(this.grids[this.grids.length-1])}this.layer.addGameObject(new Ladder(this.getGrid(3),this.getGrid(22))),this.layer.addGameObject(new Ladder(this.getGrid(25),this.getGrid(43))),this.layer.addGameObject(new Ladder(this.getGrid(40),this.getGrid(58))),this.layer.addGameObject(new Ladder(this.getGrid(81),this.getGrid(99))),this.layer.addGameObject(new Ladder(this.getGrid(55),this.getGrid(86))),this.layer.addGameObject(new Ladder(this.getGrid(49),this.getGrid(92))),this.layer.addGameObject(new Ladder(this.getGrid(12),this.getGrid(31)));var i=new Image;i.src=testPlayerImage,i.onload=e;var s=new Player(this,this.getGrid(0),i);this.layer.addGameObject(s)},FakesNLadders.prototype.getGrid=function(e){return this.grids[e]},FakesNLadders.prototype.draw=function(e){e.save(),e.fillStyle="black",e.strokeRect(0,0,this.gridSize,this.gridSize),e.beginPath();for(var t=.5;t<this.gridSize;t+=this.squareSize)e.moveTo(t,0),e.lineTo(t,this.gridSize);for(var n=.5;n<this.gridSize;n+=this.squareSize)e.moveTo(0,n),e.lineTo(this.gridSize,n);e.strokeStyle="rgba(70, 70, 70, 1)",e.lineWidth=1,e.stroke(),e.restore()},FakesNLadders.prototype.hit=function(e){},window.onload=init;
View
BIN  public/assets/fakesnladders.js.gz
Binary file not shown
View
6 public/assets/manifest.yml
@@ -1,7 +1,7 @@
---
-application.js: application-981d1f847369e74ae92ce538727d7bc5.js
-fakesnladders.js: fakesnladders-e945b8baec2bffa81924db327ec9b04a.js
-application.css: application-fcf2ec53af112896ad1c4d0c32bf554e.css
+application.js: application-e85252ec814a11abdf9c2fa86528e1df.js
+fakesnladders.js: fakesnladders-3b88c62e8009855d1e4e5d1cc75b1f98.js
+application.css: application-a2f3da0e82dbdbff2ecd12b2bead6043.css
fontawesome-webfont.eot: fontawesome-webfont-7cf1b0de49e2f8672c9ad6d9e382115f.eot
fontawesome-webfont.svg: fontawesome-webfont-4d19fdd70a080778557b652cb4868557.svg
fontawesome-webfont.ttf: fontawesome-webfont-1e29be0bb354c9f664cbca7df9a966d8.ttf

No commit comments for this range

Something went wrong with that request. Please try again.