项目作者: lordrickyz

项目描述 :
A 1D Game that players uses bubbles to pop other bubbles to clear the level.
高级语言: JavaScript
项目地址: git://github.com/lordrickyz/bubble-pop.git
创建时间: 2020-06-22T05:30:37Z
项目社区:https://github.com/lordrickyz/bubble-pop

开源协议:

下载


Bubble Pop

<>Live Site<>

SplashSite

Background:

Bubble Pop is a clone of a popular 1994 tile-matching arcade puzzle game called Puzzle Bobble.

At the start of each round, the gamespace will contain prearranged patterns of colored bubbles or balls. At the bottom of the screen, the player controls a device called a “pointer”, which aims and fires bubbles up the screen. The color of bubbles fired is randomly generated and chosen from the colors of bubbles still left on the screen. The objective of the game is to clear all the bubbles from the arena without any bubble crossing the bottom line.

GamePlay:

Users are able to control the launcher using the left arrow and right arrow keys. The spacebar is the launch button for the bubbles.

Architecture and Technology

  • HTML5 Canvas for Game Rendering
  • Vanilla JavaScript for Game Logic
  • Webpack for Bundling JS Files - v4.43.0
  • SASS for Styling - v1.26.8
  • Keymaster for Launcher Key Binding - v1.6.3

Features

In order to snap bubbles onto the board, the bubble must collide with another set bubble to allow calculations of distance and position.

Using the bubbleArea function to check if surrounding the bubbles area includes any other bubbles. If it does, when the bubble is launched, as collision occurs, the position of the bubble will be shifted towards the closes empty position and snaps onto it.

  1. let bubblesAround = game.newBubble.bubbleArea(game);
  2. if (bubble.posY > 30 && bubblesAround.length == 0) {
  3. if (bubble.angle > -180) {
  4. bubble.posX = originalX + 2;
  5. } else {
  6. bubble.posX = originalX - 2;
  7. }
  8. bubble.posY = originalY - 2;
  9. bubble.vel = prevVelocity;
  10. let correctAngle = ((this.angle - 90) * Math.PI) / 180;
  11. this.posX += this.vel * Math.cos(correctAngle);
  12. this.posY += this.vel * Math.sin(correctAngle);
  13. settled = true;
  14. }

If the row is empty, the bubble will attach to where ever it goes in:

  1. let originalX = bubble.posX;
  2. let originalY = bubble.posY;
  3. for (let i = 0; i < game.topBubbles.length; i++) {
  4. if (
  5. bubble.posX == game.topBubbles[i].posX &&
  6. bubble.posY == game.topBubbles[i].posY
  7. ) {
  8. if (originalX < game.topBubbles[i].posX) {
  9. bubble.posX = game.topBubbles[i].posX - bubble.radius * 2;
  10. } else {
  11. bubble.posX = game.topBubbles[i].posX + bubble.radius * 2;
  12. }
  13. }
  14. }

Future Directions

  • Mobile Support [React Native/Swift]
  • 2 Players Versus
  • Drop Bubbles When Bursts
  • Burst Bubbles
  • Replacing Bubbles and Launcher With Sprite Animations
  • Special Skills When Ultimate Meter is Maxed Out
    • Able to Pierce through Bubbles No Matter What Color
    • Rainbow Bubble -> Any Set of Color