Coder Social home page Coder Social logo

birds's Introduction

Birds.js

Multiplayer clone of flappy bird powered by node.js !

Birds.js

How to install

  1. Install Node.js

  2. Download the project and go into the project directory with your console

  3. Install Dependencies by typing npm install in your console

  4. [Optional] To play on different PC, you must change the websocket address for your local IP. To do it, update SOCKET_ADDR in the file sharedConstants.js

  5. Launch the server with node server.js

  6. Open your browser and navigate to http://yourserver:port/birds (by default http://localhost:4242/birds)

  7. Play ! ๐Ÿ˜„

Optional

If you play as it, player scores are stored into an array. If you want to save scores in a persistent way, you can install the birds database on a MySQL server.

  1. Install the database by importing birds.sql
  2. Update scoreSystem class to add your DB credentials. Open games_files/scoreSystem.js and set your parameters to DB_HOST, DB_USER, DB_PASS and DB_DATA
  3. Restart server. If the DB is available, the server will print the message [ScoreSystem] Database available and connected !

Node Dependencies

Birds.js uses express, jade, socket.io and mysql modules.

Features

  • Multiplayer game !

  • Parallax background

  • Persistent scores

  • Sunset effect if you're good enough ๐Ÿ˜‰

  • Easy customization - Simply edit constants to change number of pipes, space between them, bird physic, etc...

  • Mass fun !

Notes

birds's People

Contributors

benvigie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

birds's Issues

typos in files naming and templates

diff --git a/public/javascripts/game/canvasPainter.js b/public/javascripts/game/canvasPainter.js
index 836f5e4..62c6350 100644
--- a/public/javascripts/game/canvasPainter.js
+++ b/public/javascripts/game/canvasPainter.js
@@ -1,7 +1,7 @@
/*

  • Class to manage the canvas. Draw players, backgrounds, etc...
    */
    -define(['parallax', 'backgroundressources', '../../sharedConstants'], function (Parallax, bgRessources, Const) {
    +define(['parallax', 'backgroundRessources', '../../sharedConstants'], function (Parallax, bgRessources, Const) {

var HEIGHT_BETWEEN_PIPES = 150;
var NB_RESSOURCES_TO_LOAD = 2;
@@ -127,4 +127,4 @@ define(['parallax', 'backgroundressources', '../../sharedConstants'], function (
};

return (that);
-});
\ No newline at end of file
+});
diff --git a/public/javascripts/game/playerEntity.js b/public/javascripts/game/playerEntity.js
index 5376141..d66e5a0 100644
--- a/public/javascripts/game/playerEntity.js
+++ b/public/javascripts/game/playerEntity.js
@@ -5,7 +5,7 @@ define(['../../sharedConstants'], function (Const) {

var enumPlayerState = {
Unset: 1,

  • WaintingInLobby: 2,

  • WaitingInLobby: 2,
    Playing: 3,
    Died: 4
    };
    @@ -43,7 +43,7 @@ define(['../../sharedConstants'], function (Const) {
    }
    else {
    // Finally draw bird

  •    if (this._serverInfos.state == enumPlayerState.WaintingInLobby) {
    
  •    if (this._serverInfos.state == enumPlayerState.WaitingInLobby) {
    

    ctx.drawImage(spriteList[this._serverInfos.color], 0, 0, SPRITE_BIRD_WIDTH, SPRITE_BIRD_HEIGHT, this._serverInfos.posX, this._serverInfos.posY, Const.BIRD_WIDTH, Const.BIRD_HEIGHT);
    }
    // If he is ready or in game, animate the bird !
    @@ -75,11 +75,11 @@ define(['../../sharedConstants'], function (Const) {
    };

    Player.prototype.updateReadyState = function (readyState) {

  •  this._serverInfos.state = (readyState === true) ? enumPlayerState.Ready : enumPlayerState.WaintingInLobby;
    
  •  this._serverInfos.state = (readyState === true) ? enumPlayerState.Ready : enumPlayerState.WaitingInLobby;
    

    console.log(this._serverInfos.nick + ' is ' + ((this._serverInfos.state == enumPlayerState.Ready) ? 'ready !': 'not yet ready'));
    };

}

return (Player);
-});
\ No newline at end of file
+});
diff --git a/views/birds.jade b/views/birds.jade
index 2960754..3a6f6bc 100644
--- a/views/birds.jade
+++ b/views/birds.jade
@@ -1,8 +1,8 @@
doctype html
html
head

  • script(rel='stylesheet', src=wsAddress + '/socket.io/socket.io.js').
  • script(type='text/javascript', src='/socket.io/socket.io.js').
<title>Birds.js</title>

cannot connect?

Hi,
great project i really like it
i did exactly what you say in the tutorial
i got this problem
any help
flappyerror

Can't run, layout.jade missing

looks like views/layout.jade is missing!!!

Express
500 Error: /home/aritz/Dev/Birds/views/index.jade:1
> 1| extends layout
2|
3| block content
4| h1= title

ENOENT, no such file or directory '/home/aritz/Dev/Birds/views/layout.jade'

> 1| extends layout
2|
3| block content
4| h1= title
ENOENT, no such file or directory '/home/aritz/Dev/Birds/views/layout.jade'
at Object.fs.openSync (fs.js:432:18)
at Object.fs.readFileSync (fs.js:286:15)
at Parser.parseExtends (/home/aritz/Dev/Birds/node_modules/jade/lib/parser.js:470:18)
at Parser.parseExpr (/home/aritz/Dev/Birds/node_modules/jade/lib/parser.js:198:21)
at Parser.parse (/home/aritz/Dev/Birds/node_modules/jade/lib/parser.js:120:25)
at parse (/home/aritz/Dev/Birds/node_modules/jade/lib/jade.js:95:62)
at Object.exports.compile (/home/aritz/Dev/Birds/node_modules/jade/lib/jade.js:154:9)
at Object.exports.render (/home/aritz/Dev/Birds/node_modules/jade/lib/jade.js:258:15)
at Object.exports.renderFile (/home/aritz/Dev/Birds/node_modules/jade/lib/jade.js:295:18)
at View.exports.renderFile [as engine] (/home/aritz/Dev/Birds/node_modules/jade/lib/jade.js:280:21)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.