Skip to content

Flappy Bird game project built using vanilla HTML, CSS, and JavaScript

Notifications You must be signed in to change notification settings

noanonoa/flappy-bird

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FLAPPY BIRD

Flappy bird flew into an endless pipe zone (or is it?) and needs help flying through to get out.

ABOUT THE GAME

A simple side-scrolling game where the player controls a bird to fly between pipes without hitting them. Flying between each set of pipes scores 1 point and hitting them or the ground ends the game. See how long you can last and set records.

Here's a link to the game: https://noanonoa.github.io/flappy-bird/

WIREFRAME

wireframe for game screen
wireframe for collision mechanics

TECHNOLOGY

  • HTML/CSS on canvas
  • JavaScript for game logic

ASSETS

IMAGES

flappy bird theme
(src: google images)
flappy bird theme v2
(src: https://www.spriters-resource.com/fullview/59894/)

AUDIO

(src: https://www.sounds-resource.com/mobile/flappybird/sound/5309/)

SCREENSHOT

flappy bird screenshot

MVP

  • start the game with a 'press button'
  • bird falls default to gravity
  • bird flies to 'click' (might be better for mobile capabilities)
  • pipes spawn top and bottom and scroll to the left
  • track score
  • end game on collision

STRETCH GOALS

  • animate bird
  • add sounds for scoring, flying, and collision
  • a customized theme
  • game is animated while waiting for player to start game
  • night time / day time
  • add a running time to display
  • make the game web responsive

GAMEPLAN


HTML

  • container for gaming screen
  • game title
  • game screen <canvas>

CSS

  • centered game title
  • centered game screen

JavaScript

Pieces I need

  • specify canvas size
  • draw bird image
  • top pipe image
  • constant gap between pipes
  • bottom pipe image
  • score tracker
  • ready screen: game state 0
  • game over screen: game state 2
  • background image
  • ground image
  • sounds on flying, collision, scoring, falling, and game over screen

Functions I need

  • start game: game state 1
    • start on 'click' (mobile compatible)
    • spawn set of pipes with constant gap
      • if statement triggering at x-coordinate
  • bird's movement
    • gravity: bird's y-coordinate increases to fall
    • velocity's value is incremented by gravity constant
    • bird's position function updates velocity's value
    • flying: bird's y-coordinate decreases to fly on 'click'
      • eventListener 'click' (also enabled 'spacebar')
    • rotate bird upward each time it flies (smells like a challenge)
      • animation object / array of images to flip through
  • a drawing function to animate game
    • place images and loop
    • pipes' x-coordinates decrease to scroll left
      • increment score by 1 upon passing pipe
    • pipes' y-coordinates are generated randomly
    • draw background
    • draw bird
  • Game Over: game state 2
    • collision with pipes
    • collision with floor and canvas ceiling
    • cut screen
    • restart game on 'click' start button
      • display best score
      • display current score
      • reset score on start game
      • reset pipes

FINAL THOUGHTS

Working with generated images of rectangles fillRect() was proving to be more work than actually drawing canvas images from a sprite image source. This meant working with images from the beginning would just make things simpler in the long run.

Incrementing gravity to increase velocity was crucial to the feel of the game. It made the bird falling feel natural and is an important concept to learn. Flapping, or flying, meant setting the velocity to fly key-value which doesn't translate well when reading code.

Infinite pipe spawning has been a road block for me. Animating canvas images seem even more challenging.

Tracking the score was challenging due to the fact that each place value of the number had to correlate to an image of its value. No texts and fonts were used in the game.

Overall, I learned a lot of canvas tools and mechanics for JavaScript. Re-creating this game was a lot of fun and good training for various JavaScript fundamentals such as loops, functions, if-else statements, arrays, objects, and concepts.

About

Flappy Bird game project built using vanilla HTML, CSS, and JavaScript

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published