Created
June 6, 2018 23:21
-
-
Save jeremyjackson89/3983e64a515ae0fa52fc35cb8948526d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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