This commit is contained in:
John Alanbrook 2023-05-30 16:39:31 +00:00
parent 573f2a3639
commit c165e2e1f1
3 changed files with 7 additions and 6 deletions

View file

@ -155,11 +155,11 @@ killbox.polygon2d.points = Geometry.box(lvlwidth,30);
killbox.pos = [0,-lvlheight/2];
killbox.polygon2d.sensor = true;
killbox.register_hit(hit => {
if (hit.obj.tag !== 'ball')
return;
if (hit.obj.tag === 'ball') {
hit.obj.kill();
lostball();
}
}, killbox);
//Sound.play("start.wav");

View file

@ -150,10 +150,10 @@ var paddle = gameobject.clone("paddle", {
collide(hit) {
if (!(hit.obj.from === 'ball')) return;
var xdiff = hit.pos.x - this.pos.x;
if (Math.sign(xdiff) === Math.sign(hit.obj.velocity)) return;
// if (Math.sign(xdiff) === Math.sign(hit.obj.velocity)) return;
var oldvel = hit.obj.velocity;
var scaler = Math.max(Math.abs(xdiff)/30, 1);
hit.obj.velocity = hit.obj.velocity.mult([-1,1]).scale(scaler);
hit.obj.velocity = hit.obj.velocity.scale(scaler);
},
});

View file

@ -1,4 +1,5 @@
function startmenu() {
GUI.text("Press ENTER to start", Window.dimensions.scale(0.5));
GUI.text("Press ESCAPE to exit", Window.dimensions.scale(0.5).add([0,-100]));
}