Skip to content

Instantly share code, notes, and snippets.

@jeremyjackson89
Created June 6, 2018 23:21
Show Gist options
  • Save jeremyjackson89/3983e64a515ae0fa52fc35cb8948526d to your computer and use it in GitHub Desktop.
Save jeremyjackson89/3983e64a515ae0fa52fc35cb8948526d to your computer and use it in GitHub Desktop.
update: function() {
"use strict";
Point1_text.text = Point1;
Point2_text.text = Point2;
if (Point1 === 2 || Point2 === 2) {
return this.handleGameOver();
}
jeu.physics.arcade.collide(Joueur1, Balle, function() {
jeu.sound.play("Ping");
});
jeu.physics.arcade.collide(Joueur2, Balle, function() {
jeu.sound.play("Pong");
});
if (Joueur1.body.blocked.right) {
jeu.sound.play("Ping");
}
if (Balle.body.blocked.right) {
Point1 += 1;
jeu.sound.play("Point1!");
} else if (Balle.body.blocked.left) {
Point2 += 1;
jeu.sound.play("Point2!");
} else if (clavier.up.isDown) {
Joueur1.body.velocity.y = -800;
} else {
if (clavier.down.isDown) {
Joueur1.body.velocity.y = 450;
}
Joueur2.body.velocity.setTo(Balle.body.velocity.y);
Joueur2.body.velocity.x = 0;
Joueur2.body.maxVelocity.y = 175;
}
},
handleGameOver: function() {
Balle.body.velocity.setTo(0, 0);
introText.text = 'Game Over!';
introText.visible = true;
jeu.image("Game over", "images/2.jpg");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment