From ef56038486e0987668f2e2ac2ac80b44ad5feb6a Mon Sep 17 00:00:00 2001 From: loziamina Date: Tue, 17 Oct 2023 09:35:32 +0200 Subject: [PATCH 1/7] Init + empty index.html file --- index.html | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 index.html diff --git a/index.html b/index.html new file mode 100644 index 0000000..cb00957 --- /dev/null +++ b/index.html @@ -0,0 +1,11 @@ + + + + + Flappy Clone + + +

Appuyer sur la barre espace pour sauter

+
+ + \ No newline at end of file From 0a9f29f02e0d9ce789a185f1660e60169b31829d Mon Sep 17 00:00:00 2001 From: loziamina Date: Tue, 17 Oct 2023 09:40:57 +0200 Subject: [PATCH 2/7] Add game file --- index.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/index.html b/index.html index cb00957..e6008ab 100644 --- a/index.html +++ b/index.html @@ -1,4 +1,6 @@ + + From 0b91fc8dc449620b447239c92826681eadab550d Mon Sep 17 00:00:00 2001 From: loziamina Date: Tue, 17 Oct 2023 09:42:54 +0200 Subject: [PATCH 3/7] Add game file --- game.js | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 game.js diff --git a/game.js b/game.js new file mode 100644 index 0000000..15dbdfa --- /dev/null +++ b/game.js @@ -0,0 +1,101 @@ +var game = new Phaser.Game(400, 490, Phaser.AUTO, 'game'); + +var mainState = { + + preload: function() { + game.stage.backgroundColor = '#71c5cf'; + bird = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyAQMAAAAk8RryAAAABlBMVEXSvicAAABogyUZAAAAGUlEQVR4AWP4DwYHMOgHDEDASCN6lMYV7gChf3AJ/eB/pQAAAABJRU5ErkJggg=="; + pipe = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyAQMAAAAk8RryAAAABlBMVEV0vy4AAADnrrHQAAAAGUlEQVR4AWP4DwYHMOgHDEDASCN6lMYV7gChf3AJ/eB/pQAAAABJRU5ErkJggg=="; + game.load.image('bird', bird); + game.load.image('pipe', pipe); + }, + + create: function() { + game.physics.startSystem(Phaser.Physics.ARCADE); + + this.pipes = game.add.group(); + this.pipes.enableBody = true; + this.pipes.createMultiple(20, 'pipe'); + this.timer = this.game.time.events.loop(1500, this.addRowOfPipes, this); + + this.bird = this.game.add.sprite(100, 245, 'bird'); + game.physics.arcade.enable(this.bird); + this.bird.body.gravity.y = 1000; + + // New anchor position + this.bird.anchor.setTo(-0.2, 0.5); + + var spaceKey = this.game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR); + spaceKey.onDown.add(this.jump, this); + + this.score = 0; + this.labelScore = this.game.add.text(20, 20, "0", { font: "30px Arial", fill: "#ffffff" }); + + // Add the jump sound + this.jumpSound = this.game.add.audio('jump'); + }, + + update: function() { + if (this.bird.inWorld == false) + this.restartGame(); + + game.physics.arcade.overlap(this.bird, this.pipes, this.hitPipe, null, this); + + // Rotate the bird + }, + + jump: function() { + // If the bird is dead, he can't jump + if (this.bird.alive == false) + return; + + this.bird.body.velocity.y = -350; + + // Jump animation + + }, + + hitPipe: function() { + // If the bird has already hit a pipe, we have nothing to do + if (this.bird.alive == false) + return; + + // Set the alive property of the bird to false + this.bird.alive = false; + + // Prevent new pipes from appearing + this.game.time.events.remove(this.timer); + + // Go through all the pipes, and stop their movement + this.pipes.forEachAlive(function(p){ + p.body.velocity.x = 0; + }, this); + }, + + restartGame: function() { + game.state.start('main'); + }, + + addOnePipe: function(x, y) { + var pipe = this.pipes.getFirstDead(); + + pipe.reset(x, y); + pipe.body.velocity.x = -200; + pipe.checkWorldBounds = true; + pipe.outOfBoundsKill = true; + }, + + addRowOfPipes: function() { + var hole = Math.floor(Math.random()*5)+1; + + for (var i = 0; i < 8; i++) + if (i != hole && i != hole +1) + this.addOnePipe(400, i*60+10); + + this.score += 1; + this.labelScore.text = this.score; + }, +}; + +game.state.add('main', mainState); +game.state.start('main'); \ No newline at end of file From f2a832ac6dd0a13173f8fd562d8298da52dd8e80 Mon Sep 17 00:00:00 2001 From: loziamina Date: Tue, 17 Oct 2023 09:50:56 +0200 Subject: [PATCH 4/7] satisfait du code --- game.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/game.js b/game.js index 15dbdfa..61529af 100644 --- a/game.js +++ b/game.js @@ -42,6 +42,8 @@ var mainState = { game.physics.arcade.overlap(this.bird, this.pipes, this.hitPipe, null, this); // Rotate the bird + if (this.bird.angle < 20) + this.bird.angle += 1; }, jump: function() { @@ -52,6 +54,7 @@ var mainState = { this.bird.body.velocity.y = -350; // Jump animation + game.add.tween(this.bird).to({angle: -20}, 100).start(); }, From a8771909a4462641cc702807d14767d522da7244 Mon Sep 17 00:00:00 2001 From: loziamina Date: Tue, 17 Oct 2023 09:55:11 +0200 Subject: [PATCH 5/7] changer background --- game.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/game.js b/game.js index 61529af..90f3e88 100644 --- a/game.js +++ b/game.js @@ -3,7 +3,7 @@ var game = new Phaser.Game(400, 490, Phaser.AUTO, 'game'); var mainState = { preload: function() { - game.stage.backgroundColor = '#71c5cf'; + game.stage.backgroundColor = '#FF6A5E'; bird = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyAQMAAAAk8RryAAAABlBMVEXSvicAAABogyUZAAAAGUlEQVR4AWP4DwYHMOgHDEDASCN6lMYV7gChf3AJ/eB/pQAAAABJRU5ErkJggg=="; pipe = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyAQMAAAAk8RryAAAABlBMVEV0vy4AAADnrrHQAAAAGUlEQVR4AWP4DwYHMOgHDEDASCN6lMYV7gChf3AJ/eB/pQAAAABJRU5ErkJggg=="; game.load.image('bird', bird); From 053bf7146d66d8f039dd66bcc6353e8415f246b0 Mon Sep 17 00:00:00 2001 From: loziamina Date: Tue, 17 Oct 2023 09:56:51 +0200 Subject: [PATCH 6/7] changer background --- game.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/game.js b/game.js index 61529af..75eac4e 100644 --- a/game.js +++ b/game.js @@ -3,7 +3,7 @@ var game = new Phaser.Game(400, 490, Phaser.AUTO, 'game'); var mainState = { preload: function() { - game.stage.backgroundColor = '#71c5cf'; + game.stage.backgroundColor = '#D0FFC2'; bird = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyAQMAAAAk8RryAAAABlBMVEXSvicAAABogyUZAAAAGUlEQVR4AWP4DwYHMOgHDEDASCN6lMYV7gChf3AJ/eB/pQAAAABJRU5ErkJggg=="; pipe = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyAQMAAAAk8RryAAAABlBMVEV0vy4AAADnrrHQAAAAGUlEQVR4AWP4DwYHMOgHDEDASCN6lMYV7gChf3AJ/eB/pQAAAABJRU5ErkJggg=="; game.load.image('bird', bird); From eae2331656786d90b1037faef96f848967fc7a00 Mon Sep 17 00:00:00 2001 From: loziamina <90446832+loziamina@users.noreply.github.com> Date: Tue, 17 Oct 2023 11:08:30 +0200 Subject: [PATCH 7/7] Add My name on README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 21b2d73..c036e4f 100644 --- a/README.md +++ b/README.md @@ -326,3 +326,4 @@ Une fois réalisée, vous pouvez observer sur le projet original toutes les prop - Théo Charron - - Lucas SENOVILLE - - Walid DJEMMAA - +- Amina LOZI -