Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

nog ff een paar bugs geplet

  • Loading branch information...
commit 7ae18b2bfb2d7c1451947c791a4d493bbdc0efb1 1 parent 50daf54
Marcus Klaas de Vries authored
View
2  client/DOM.js
@@ -330,7 +330,7 @@ function createDomManager(game) {
resizeChat();
};
- domManager.splicePlayerList = function() {
+ domManager.splicePlayerList = function(player) {
playerList.removeChild(player.row);
resizeChat();
};
View
37 client/GameEngine.js
@@ -23,14 +23,13 @@ var rareNaam = (function() { // zodat we het zien als sommige plekken nog op een
var modifiedInputs = 0;
var redraws = 0;
var countdown = 0;
- var correctionTick = 0;
var tock = 0;
/* private methods */
/* this only resets things like canvas, but keeps the player info */
function reset() {
- correctionTick = 0;
- GameEngine.tick = -1;
+ GameEngine.correctionTick = 0;
+ GameEngine.tick = tock = -1;
redraws = 0;
adjustGameTimeMessagesReceived = 0;
modifiedInputs = 0;
@@ -45,6 +44,7 @@ var rareNaam = (function() { // zodat we het zien als sommige plekken nog op een
document.getElementById('winAnnouncer').style.display = 'none';
GameEngine.pencil.reset();
+ /* TODO: reset pens too? */
}
function resetPlayers() {
@@ -71,7 +71,8 @@ var rareNaam = (function() { // zodat we het zien als sommige plekken nog op een
var tickDelta = (c & (16 + 32 + 64)) >> 4;
tickDelta |= d << 3;
- correctionTick = Math.min(GameEngine.localPlayer.inputs[input].tick += tickDelta, correctionTick);
+ GameEngine.correctionTick = Math.min(GameEngine.localPlayer.inputs[input].tick += tickDelta,
+ GameEngine.correctionTick);
return true;
}
@@ -152,7 +153,7 @@ var rareNaam = (function() { // zodat we het zien als sommige plekken nog op een
player.inputs.push(new Turn(newTurn, tick, 0, 0, false));
if(tick <= Math.floor(tock))
- correctionTick = Math.min(correctionTick, tick);
+ GameEngine.correctionTick = Math.min(GameEngine.correctionTick, tick);
}
function interpretMsg(msg) {
@@ -294,7 +295,7 @@ var rareNaam = (function() { // zodat we het zien als sommige plekken nog op een
// simulate to finalTick
tock = GameEngine.tick = Math.max(GameEngine.tick, obj.finalTick);
- correctionTick = Math.min(correctionTick, obj.finalTick);
+ GameEngine.correctionTick = Math.min(GameEngine.correctionTick, obj.finalTick);
GameEngine.revertBackup();
var player = (obj.winnerId != -1) ? GameEngine.getPlayer(obj.winnerId) : null;
@@ -331,7 +332,7 @@ var rareNaam = (function() { // zodat we het zien als sommige plekken nog op een
GameEngine.domManager.buildGameList(obj.games);
break;
case 'segments':
- this.canvasManager.drawDebugSegments(GameEngine.baseContext, obj.segments);
+ GameEngine.canvasManager.drawDebugSegments(GameEngine.baseContext, obj.segments);
debugSegments = debugSegments.concat(obj.segments);
break;
case 'stopSpamming':
@@ -369,11 +370,10 @@ var rareNaam = (function() { // zodat we het zien als sommige plekken nog op een
}
function realStart() {
- GameEngine.baseContext.drawImage(canvases[0], 0, 0, this.width, this.height);
+ GameEngine.baseContext.drawImage(canvases[0], 0, 0, GameEngine.width, GameEngine.height);
GameEngine.audioController.playSound('gameStart');
GameEngine.setGameState('playing');
GameEngine.sendMsg('enableInput', {});
- GameEngine.tick = 0;
gameloop();
}
@@ -413,7 +413,7 @@ var rareNaam = (function() { // zodat we het zien als sommige plekken nog op een
}
GameEngine.tick = Math.min(nextIntegerTick, endTick);
- correctionTick = Math.ceil(GameEngine.tick);
+ GameEngine.correctionTick = Math.ceil(GameEngine.tick);
tock = Math.max(0, GameEngine.tick - tickTockDifference);
}
@@ -481,6 +481,7 @@ var rareNaam = (function() { // zodat we het zien als sommige plekken nog op een
this.width = 0;
this.height = 0;
this.velocity = 0;
+ this.correctionTick = 0;
this.tick = 0;
this.holeSize = this.holeFreq = 0;
this.pencilMode = 'off';
@@ -882,14 +883,14 @@ var rareNaam = (function() { // zodat we het zien als sommige plekken nog op een
var ceiledTick = Math.ceil(this.tick);
/* false alarm, no revert required */
- if(correctionTick >= ceiledTick)
+ if(this.correctionTick >= ceiledTick)
return;
redraws++;
this.displayDebugStatus();
/* calculate closest restore point */
- for(var stateIndex = backupStates.length - 1; correctionTick < ceiledTick - backupStates[stateIndex]; stateIndex--);
+ for(var stateIndex = backupStates.length - 1; this.correctionTick < ceiledTick - backupStates[stateIndex]; stateIndex--);
/* reset next state to this point */
for(var i in players) {
@@ -900,7 +901,7 @@ var rareNaam = (function() { // zodat we het zien als sommige plekken nog op een
/* copy to next canvas */
var nextContext = this.contexts[stateIndex + 1];
nextContext.drawImage(canvases[stateIndex], 0, 0, this.width, this.height);
- correctionTick = ceiledTick - backupStates[stateIndex + 1];
+ this.correctionTick = ceiledTick - backupStates[stateIndex + 1];
/* simulate every player up to next backup point */
this.updateContext(stateIndex + 1, true);
@@ -915,13 +916,13 @@ var rareNaam = (function() { // zodat we het zien als sommige plekken nog op een
GameEngine.updateContext = function(stateIndex, floorTick) {
for(var i in players) {
var player = players[i];
- var tick = player.isLocal ? this.tick : tock;
- tick -= backupStates[stateIndex];
+ var playerTick = player.isLocal ? this.tick : tock;
+ playerTick -= backupStates[stateIndex];
if(floorTick)
- tick = Math.floor(tick);
+ playerTick = Math.floor(playerTick);
- player.simulate(tick, this.contexts[stateIndex], player.states[stateIndex]);
+ player.simulate(playerTick, this.contexts[stateIndex], player.states[stateIndex]);
}
this.drawCrosses(stateIndex);
@@ -1013,7 +1014,7 @@ var rareNaam = (function() { // zodat we het zien als sommige plekken nog op een
this.canvasManager.drawMapSegments(this.contexts[0]);
this.canvasManager.drawPencilSegments(this.contexts[0]);
- correctionTick = -backupStates[1] - 1;
+ this.correctionTick = -backupStates[1] - 1;
this.revertBackup();
};
View
3  client/Pencil.js
@@ -146,11 +146,12 @@ Pen.prototype.reset = function() {
Pen.prototype.doTick = function() {
var canvasManager = this.player.game.canvasManager;
+ var gameTick = this.player.game.tick;
if(!this.player.isLocal)
while(this.visibleIndex < this.seg.length)
canvasManager.drawSegment(this.seg[this.visibleIndex++], this.player.color, pencilAlpha);
- while(this.solidIndex < this.seg.length && this.seg[this.solidIndex].tick <= game.tick)
+ while(this.solidIndex < this.seg.length && this.seg[this.solidIndex].tick <= gameTick)
canvasManager.drawSegment(this.seg[this.solidIndex++], this.player.color, 1);
}
View
4 client/Player.js
@@ -63,8 +63,10 @@ Player.prototype.finalSteer = function(obj) {
this.inputs[i + 1] = new Turn(0, tick, obj.x, obj.y, true);
this.finalTick = tick;
- if(tick <= Math.ceil(this.states[backupStates.length - 1].tick))
+ if(tick <= Math.ceil(this.states[backupStates.length - 1].tick)) {
this.game.correctionTick = Math.min(this.game.correctionTick, tick);
+ this.game.domManager.gameMessage('player died, new correctionTick = ' + this.game.correctionTick);
+ }
}
Player.prototype.setSegmentStyle = function(ctx, inHole) {
View
6 client/game.js
@@ -1,4 +1,4 @@
-/* global vars */
+/* global vars. TODO: move to GameEngine */
var enableSound = true;
var joinedLink = false;
@@ -13,8 +13,8 @@ else if(location.href.indexOf('C:/Dropbox') != -1)
serverURL = "ws://localhost:7681";
/* visual stuff */
-var vSync = false;
-var maxCanvasStretch = 1.10; // max 20% stretch in either direction
+var vSync = true;
+var maxCanvasStretch = 1.10; // max 10% stretch in either direction
var holeAlpha = 0.2;
var lineWidth = 3; // only visual, does not influence collisions
var lineCapStyle = 'round';
View
25 client/misc.js
@@ -68,16 +68,6 @@ Segment.prototype.draw = function(ctx) {
ctx.lineTo(this.x2, this.y2);
}
-/* FIXME: DO NOT USE THIS! use canvasmanager method instead! */
-Segment.prototype.stroke = function(ctx, color, alpha) {
- ctx.beginPath();
- canvasManager.setLineColor(ctx, color, alpha);
- ctx.lineCap = alpha == 1 ? lineCapStyle : 'butt';
- this.draw(ctx);
- ctx.stroke();
- ctx.lineCap = lineCapStyle;
-}
-
function TimedSegment(x1, y1, x2, y2, tick) {
Segment.call(this, x1, y1, x2, y2);
this.tick = tick;
@@ -252,10 +242,21 @@ function createCanvasManager(game) {
ctx.lineWidth = lineWidth;
},
+ /* all canvases */
drawSegment: function(seg, color, alpha) {
for(var i = 0; i < backupStates.length; i++)
- seg.stroke(game.contexts[i], color, alpha);
- },
+ this.strokeSegment(seg, game.contexts[i], color, alpha);
+ },
+
+ /* specific canvas */
+ strokeSegment: function(seg, ctx, color, alpha) {
+ ctx.beginPath();
+ this.setLineColor(ctx, color, alpha);
+ ctx.lineCap = alpha == 1 ? lineCapStyle : 'butt';
+ seg.draw(ctx);
+ ctx.stroke();
+ ctx.lineCap = lineCapStyle;
+ },
drawMapSegments: function(ctx) {
ctx.fillStyle = canvasColor;
View
2  test-server/server.h
@@ -78,7 +78,7 @@
#define ULTRA_VERBOSE 0
#define SHOW_WARNING 0
#define GOD_MODE 0
-#define SEND_SEGMENTS 0
+#define SEND_SEGMENTS 10
#define SAVE_COLLISION_TO_FILE 0
#define DEBUGPOS 0
#define KEEP_PLAYING_ONE_ALIVE 0
Please sign in to comment.
Something went wrong with that request. Please try again.