HTML and CSS Reference
In-Depth Information
} else if(this.p.x > Q.width - this.p.w) {
this.p.x = Q.width - this.p.w;
}
this._super(dt);
}
});
Q.Ball = Q.Sprite.extend({
init: function() {
this._super({
sheet: 'ball',
speed: 200,
dx: 1,
dy: -1,
});
this.p.y = Q.height / 2 - this.p.h;
this.p.x = Q.width / 2 + this.p.w / 2;
},
step: function(dt) {
var p = this.p;
p.x += p.dx * p.speed * dt;
p.y += p.dy * p.speed * dt;
if(p.x < 0) {
p.x = 0;
p.dx = 1;
} else if(p.x > Q.width - p.w) {
p.dx = -1;
p.x = Q.width - p.w;
}
if(p.y < 0) {
p.y = 0;
p.dy = 1;
} else if(p.y > Q.height - p.h) {
p.dy = -1;
p.y = Q.height- p.h;
}
this._super(dt);
}
});
Search WWH ::




Custom Search