Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 38 additions & 34 deletions public/game.html
Original file line number Diff line number Diff line change
@@ -1,39 +1,43 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="icon" href="./game/assets/fbug_01.png" />
<title>FlappyBug! a Multiplayer Geeky Version of FlappyBird</title>
<meta name="description" content="FlappyBug! a Multiplayer Geeky Version of FlappyBird">
<meta name="author" content="Amala-Hakeem-Benyam during the MLH Fellowship">
<link rel="stylesheet" href="css/index.css">
<link href='https://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet'>
<script src="//cdn.jsdelivr.net/npm/phaser@3.52.0/dist/phaser.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="js/Bug.js"></script>
<script src="js/game.js"></script>
<script src="js/GameScene.js"></script>
<script src="js/LoaderScene.js"></script>
<script src="js/MenuScene.js"></script>
<script src="js/GameOverScene.js"></script>
<script src="js/WaitingScene.js"></script>
<script src="js/helper.js"></script>
</head>
<body>

<head>
<meta charset="utf-8">
<link rel="icon" href="./game/assets/fbug_01.png" />
<title>FlappyBug! a Multiplayer Geeky Version of FlappyBird</title>
<meta name="description" content="FlappyBug! a Multiplayer Geeky Version of FlappyBird">
<meta name="author" content="Amala-Hakeem-Benyam during the MLH Fellowship">
<link rel="stylesheet" href="css/index.css">
<link href='https://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet'>
<script src="//cdn.jsdelivr.net/npm/phaser@3.52.0/dist/phaser.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="js/Bug.js"></script>
<script src="js/game.js"></script>
<script src="js/GameScene.js"></script>
<script src="js/LoaderScene.js"></script>
<script src="js/MenuScene.js"></script>
<script src="js/GameOverScene.js"></script>
<script src="js/WaitingScene.js"></script>
<script src="js/helper.js"></script>
<script src="js/_gvars.js"></script>
</head>

<body>
<h1 class="hidden-p">Hidden</h1>
<nav>
<div>
<img src="./game/assets/fbug_01.png" id="nav-icon">
<div class="nav-fb-holder">
<span class="nav-fb" id="nav-flappy">Flappy</span>
<span class="nav-fb" id="nav-bug">Bug</span>
</div>
<nav>
<div>
<img src="./game/assets/fbug_01.png" id="nav-icon">
<div class="nav-fb-holder">
<span class="nav-fb" id="nav-flappy">Flappy</span>
<span class="nav-fb" id="nav-bug">Bug</span>
</div>
</nav>
<br />
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io();
</script>
</body>
</div>
</nav>
<br />
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io();
</script>
</body>

</html>
32 changes: 18 additions & 14 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<!DOCTYPE html>

<html>

<head>
<link href="https://fonts.googleapis.com/css?family=Amatic+SC|Raleway" rel="stylesheet">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="./css/landing.css">
</head>

<body>

<header>
<h2><a href="#" style="color: #3f826d;">FlappyBug</a></h2>
<nav >
<nav>
<li><a href="#howto" style="color: #3f826d;">How to Play</a></li>
<li><a href="#team" style="color: #3f826d;">Team</a></li>
</nav>
Expand All @@ -25,20 +27,20 @@ <h3>Enjoy :)</h3>
</div>
</section>

<section class="destinations" id = "howto">
<section class="destinations" id="howto">
<h3 class="title">How to Play</h3>
<p>
Use <strong>space</strong> key or <strong>click</strong> to make the flappy bug jump :)
Use <strong>space</strong> key or <strong>click</strong> to make the flappy bug jump :)
</p>
<hr>


</section>

<section class="packages" id="team">
<h3 class="title">Team Members</h3>
<p>
We're team of 3 people from pod 2.1.1
We're team of 3 people from pod 2.1.1
</p>
<hr>

Expand All @@ -47,16 +49,17 @@ <h3 class="title">Team Members</h3>
<div class="wpos-box-shadow-img">
<div class="wpos-inner">
<img src="./game/assets/amala.jpg" alt="" />
</div>
</div>
</div>

<h4>Amala</h4>
<!-- - name: "Amala Abraham"
twitter: "https://twitter.com/amala_abraham"
linkedin: "https://www.linkedin.com/in/amalaabraham3/"
github: "https://github.com/amalaabraham" -->

<p>Web developer who is passionate about solving real-world problems and an explorer who loves exploring new things and places.</p>
<p>Web developer who is passionate about solving real-world problems and an explorer who loves exploring new
things and places.</p>
<!-- <div><ul style="display: flex; justify-items: center; ">
<li><a href="https://twitter.com/amala_abraham#"><i class="fa fa-twitter-square fa-2x"></i></a></li>
<li><a href="https://www.linkedin.com/in/amalaabraham3/"><i class="fa fa-facebook-square fa-2x"></i></a></li>
Expand All @@ -67,26 +70,27 @@ <h4>Amala</h4>
<div class="wpos-box-shadow-img">
<div class="wpos-inner">
<img src="./game/assets/benyam.jpg" alt="" />
</div>
</div>
</div>

<h4>Benyam</h4>
<p>I am Benyam a mobile and full-stack web developer. I put myself to the world in such a way that the rest of the world says 'Wow that's cool!' . </p>

<p>I am Benyam a mobile and full-stack web developer. I put myself to the world in such a way that the rest of
the world says 'Wow that's cool!' . </p>

</li>
<li>

<div class="wpos-box-shadow-img">
<div class="wpos-inner">
<img src="./game/assets/hakeem.jpg" alt="" />
</div>
</div>
</div>



<h4>Hakeem </h4>
<p>I'm a 2nd year CS Student at ESI Algiers, NLP enthusiast and a Classical&Jazz Guitar Player!</p>
</li>

</ul>
</section>

Expand Down
35 changes: 19 additions & 16 deletions public/js/Bug.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
var BugConfig = {
jumpVelocity: -400,
gravityVelocity: 200,
gravityAngularVelocity: 80,
jumpAngularVelocity: -160,
jumpVelocity: -400, // when jumping add up-acceleration
gravityVelocity: 200, // bug is always falling down
gravityAngularVelocity: 80, // bug when falling down rolls clock-wise for better effect
jumpAngularVelocity: -160, // when bug jumps -> bug rotate left for effect
};

class Bug {
constructor(scene, gameWidth, gameHeight, hasPriority, isOpponent) {
this.scene = scene;
this.gameWidth = gameWidth;
this.gameHeight = gameHeight;
this.player = null;
this.hasGameStarted = false;
this.hasPriority = hasPriority;
this.isOpponent = isOpponent;
this.scene = scene; // init scene
this.gameWidth = gameWidth; // init game Width
this.gameHeight = gameHeight; // init game Height
this.player = null; // phaser sprite
this.hasGameStarted = false; // did the game start
this.hasPriority = hasPriority; // true if first to waiting room (on multiplay)
this.isOpponent = isOpponent; // got an opponent ? multiplay mode ?
}

render() {
Expand All @@ -32,19 +32,21 @@ class Bug {
return this;
}

// create player's Bug
this.player = this.scene.physics.add.sprite(
Math.floor(gameWidth / 2),
bugY,
"bug"
);

return this;
}

initPlayer() {
this.player.body.velocity.y = BugConfig.gravityVelocity;
this.player.body.angularVelocity = BugConfig.gravityAngularVelocity;
this.player.body.allowRotation = true;
this.player.body.velocity.x = 240;
this.player.body.velocity.x = 240; // always moving forward
}

startGame() {
Expand All @@ -56,6 +58,7 @@ class Bug {
stopGame() {
this.hasGameStarted = false;
this.player.enableRotation = false;
// reset accelerations
this.player.body.velocity.y = 0;
this.player.body.angularVelocity = 0;
}
Expand All @@ -66,7 +69,7 @@ class Bug {
this.player.body.velocity.y = BugConfig.jumpVelocity;
this.player.body.angularVelocity = BugConfig.jumpAngularVelocity;

setTimeout(() => {
setTimeout(() => { // reset jump velocities after some time
if (!this.hasGameStarted) return;
this.player.body.velocity.y = BugConfig.gravityVelocity;
this.player.body.angularVelocity = BugConfig.gravityAngularVelocity;
Expand Down Expand Up @@ -101,12 +104,12 @@ class Bug {

let y = this.player.body.y;

let bottomLimit = 100;
let bottomLimit = 100; // bottom limit to implement game edge collisions

if (y < 0) this.player.body.y = 0;
if (y < 0) this.player.body.y = 0; // top-collisions

if (y > gameHeight - bottomLimit)
this.player.body.y = gameHeight - bottomLimit;
this.player.body.y = gameHeight - bottomLimit; // can't sink below game edges
}

alertOponentOfJump() {
Expand Down
25 changes: 5 additions & 20 deletions public/js/GameOverScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,17 @@ class GameOverScene extends Phaser.Scene {
this.score = score;
}
create(data) {
let label = this.add.text(gameWidth / 2, gameHeight / 2, "Game Over!", {
fontSize: "50px",
fontFamily: "PS2P",
align: "center",
fill: "blue",
});
let label = this.add.text(gameWidth / 2, gameHeight / 2, "Game Over!", Label0Css("50px", "blue")); // Game Over Label
label.setOrigin(0.5, 0.5);
this.showRetryAndScore();
}

showRetryAndScore() {
let backLabel = this.add
.text(10, gameHeight - 30, "<- Retry", {
fontSize: "15px",
fontFamily: "PS2P",
align: "center",
fill: "#fff",
})
.text(10, gameHeight - 30, "<- Retry", Label0Css("15px", "#fff"))
.setDepth(1);
backLabel.setInteractive({ useHandCursor: true });
console.log(typeof this.score);
DEBUG(typeof this.score);
if (typeof this.score === "number") {
const scoreLabel = this.add
.text(
Expand All @@ -38,17 +28,12 @@ class GameOverScene extends Phaser.Scene {
`Your Score: ${this.score} High Score: ${localStorage.getItem(
"flappyhighscore"
)}`,
{
fontSize: "15px",
fontFamily: "PS2P",
align: "center",
fill: "#fff",
}
Label0Css("15px", "#fff")
)
.setDepth(1);
}

backLabel.on("pointerup", () => {
backLabel.on("pointerup", () => { // go back upon click
this.scene.start("MenuScene");
});
}
Expand Down
Loading