HTML and CSS Reference
In-Depth Information
step: function(dt) {
var lastDirection = this.p.direction;
this.p.direction = null;
if(Q.inputs['left']) {
this.p.direction = 'left';
} else if(Q.inputs['right']) {
this.p.direction = 'right';
}
this._super(dt);
if(lastDirection != this.p.direction) {
socket.emit("move",[this.p.direction,this.p.x]);
}
}
});
Q.EnemyPaddle = Q.Paddle.extend({
init: function(props) {
this._super(props);
var self = this, p = this.p;
socket.on("move",function(data) {
p.direction = data[0];
p.x = data[1];
self.step(delay/1000);
});
}
});
Q.Ball = Q.Sprite.extend({
init: function(props) {
this._super(_(props||{}).defaults({
x: 200, y: 100,
w: 10, h: 10,
dx: -1, dy: -1,
speed: 100,
ballRate: 0.5,
ballSend: 0.5
}));
var self = this, p = this.p;
if(gameType == 'slave') {
socket.on("ball",function(pos) {
p.x = pos.x;
p.y = pos.y;
p.dx = pos.dx;
p.dy = pos.dy;
self.step(delay/1000);
});
 
Search WWH ::




Custom Search