Permalink
Browse files

paar kleine bugs

  • Loading branch information...
1 parent 6ecb0e9 commit b5338c2cc7e555f2d7d694d375a26e20e5e32889 @rdragon rdragon committed Apr 5, 2012
Showing with 24 additions and 19 deletions.
  1. +1 −1 client/DOM.js
  2. +0 −1 client/Editor.js
  3. +16 −13 client/Pencil.js
  4. +1 −1 client/misc.js
  5. +2 −2 test-server/helper.c
  6. +4 −1 test-server/pencil.c
View
@@ -268,7 +268,7 @@ function createDomManager(game) {
if(location.href.indexOf('C:/Dropbox') != -1) {
playerName = 'piet';
document.getElementById('sound').checked = false;
- game.audioController.enableSound = false; // huh waarom werkt dit niet
+ game.audioController.enableSound = false;
document.getElementById('minplayers').value = 1;
}
View
@@ -59,7 +59,6 @@ function createEditor(game) {
seg.angle = getAngle(seg.x2 - seg.x1, seg.y2 - seg.y1);
break;
case 'teleport':
- //TODO: some visual feedback for these return statements - wat do u mean?
if(getLength(seg.x2 - seg.x1, seg.y2 - seg.y1) < minTeleportSize ||
(seg.teleportId = getNextTeleportId()) == -1)
return;
View
@@ -14,7 +14,8 @@ function createPencil(game, mouse) {
}
function move() {
- var seg = pos.link(mouse);
+ var newpos = mouse.clone();
+ var seg = pos.link(newpos);
var d = seg.getLength();
if(ink < d + epsilon) {
@@ -23,20 +24,22 @@ function createPencil(game, mouse) {
if(ink < epsilon)
return;
- var v = mouse.clone().subtract(pos);
- v.scale((ink - epsilon) / d);
- v.x = v.x < 0 ? Math.ceil(v.x) : Math.floor(v.x);
- v.y = v.y < 0 ? Math.ceil(v.y) : Math.floor(v.y);
- pos.add(v);
- ink -= v.getLength();
- }
- else {
- mouse.copyTo(pos);
- ink -= d;
+ newpos.subtract(pos);
+ newpos.scale((ink - epsilon) / d);
+ newpos.x = newpos.x < 0 ? Math.ceil(newpos.x) : Math.floor(newpos.x);
+ newpos.y = newpos.y < 0 ? Math.ceil(newpos.y) : Math.floor(newpos.y);
+ newpos.add(pos);
+
+ seg.setEnd(newpos);
+ d = seg.getLength();
}
+ if(d == 0)
+ return;
+
+ ink -= d;
+ newpos.copyTo(pos);
appendpos();
- seg.setEnd(pos);
canvasManager.drawSegment(seg, game.localPlayer.color, pencilAlpha);
}
@@ -56,7 +59,7 @@ function createPencil(game, mouse) {
},
lower: function() {
- if(!this.isLowerable()) // was eerst pencil.isLowerable() maar global pencil bestaat niet meer.. dit zou ook moeten werken (tog?) anders deze literal ff naam geven (bijv pencil ;P)
+ if(!this.isLowerable())
return;
mouse.copyTo(pos);
View
@@ -37,7 +37,7 @@ AudioController.prototype.addSound = function(name, file, formats) {
}
AudioController.prototype.playSound = function(name) {
- if(!enableSound || typeof this.sounds[name] != 'object')
+ if(!this.enableSound || typeof this.sounds[name] != 'object')
return;
this.sounds[name][Math.floor(Math.random() * this.sounds[name].length)].play();
View
@@ -598,11 +598,11 @@ char *getFileExt(char *path) {
#ifdef _WIN32
#include <windows.h>
- inline void msleep(unsigned int msecs) {
+ void msleep(unsigned int msecs) {
Sleep(msecs);
}
#else
- inline void msleep(unsigned int msecs) {
+ void msleep(unsigned int msecs) {
usleep(1000 * msecs);
}
#endif
View
@@ -93,7 +93,7 @@ void handlepencilmsg(cJSON *json, struct user *usr) {
mousedown = 0;
}
else {
- double d = getlength(p->x - x, p->y - y); // dubbel-D ? ;-) => whaha
+ double d = getlength(p->x - x, p->y - y);
if(!p->down) {
warningplayer(usr, "error: pencil move: pencil not down\n");
@@ -108,6 +108,9 @@ void handlepencilmsg(cJSON *json, struct user *usr) {
if(d < INK_MIN_DISTANCE)
p->down = 0;
+ if(p->x == x && p->y == y)
+ break;
+
p->ink -= d;
queuepencilseg(p, x, y);
}

0 comments on commit b5338c2

Please sign in to comment.