Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge #49

Merged
merged 20 commits into from
May 3, 2024
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
43 changes: 43 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["master"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload entire repository
path: '.'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
45 changes: 36 additions & 9 deletions js/ball.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,14 @@ class Ball{
else{
this.useless = true;
}

}
else{
ballMissSound.play();
gameOver = true;
status = "You are Dead";
}

}
}

Expand Down Expand Up @@ -114,12 +116,40 @@ class Ball{
} // ball center inside paddle
} // end of ballPaddleHandling

brickHandling(){
//have to take into consideration how ball is travelling left to right,r

let prevBallX = this.x - this.velocityX;
let prevBallY = this.y - this.velocityY;
let prevBrickCol = Math.floor(prevBallX / BRICK_WIDTH);
let prevBrickRow = Math.floor(prevBallY / BRICK_HEIGHT);
let bothTestsFailed = true;

let ballBrickCol,ballBrickRow;

//if ball is coming towards brick from left
// x,y is center of ball
if(prevBallX < this.x){
ballBrickCol = Math.floor((this.x + (BALL_DIA/2)) / BRICK_WIDTH) ;
}

//if ball is coming towards brick from right
if(prevBallX > this.x){
ballBrickCol = Math.floor((this.x - (BALL_DIA/2)) / BRICK_WIDTH) ;
}

//if ball is coming towards brick from top
if(prevBallY < this.y){
ballBrickRow = Math.floor((this.y + (BALL_DIA/2)) / BRICK_HEIGHT) ;
}

//if ball is coming towards brick from bottom
if(prevBallY > this.y){
ballBrickRow = Math.floor((this.y - (BALL_DIA/2)) / BRICK_HEIGHT) ;

}


brickHandling(){
let ballBrickCol = Math.floor(this.x / (BRICK_WIDTH )) ;
let ballBrickRow = Math.floor(this.y / (BRICK_HEIGHT )) ;
if(ballBrickCol >= 0 && ballBrickCol < BRICK_COLS && ballBrickRow >= 0 && ballBrickRow < BRICK_ROWS) {
let brickIndexUnderBall = rowColToArrayIndex(ballBrickCol, ballBrickRow);
if(bricks[brickIndexUnderBall] > 0) {
Expand All @@ -132,7 +162,7 @@ class Ball{
this.speedIncrement(0.02);
this.chainBounce = true;
ballBrickSound.play();
let random = Math.floor(Math.random() * 10);
let random = Math.floor(Math.random() * 20);
if(random == 0){
let decideWhichPowerup = Math.ceil(Math.random() * 6);
let powerup;
Expand Down Expand Up @@ -164,11 +194,7 @@ class Ball{
goToNextLevel();
} // out of bricks

let prevBallX = this.x - this.velocityX;
let prevBallY = this.y - this.velocityY;
let prevBrickCol = Math.floor(prevBallX / BRICK_WIDTH);
let prevBrickRow = Math.floor(prevBallY / BRICK_HEIGHT);
let bothTestsFailed = true;


if(!redBall){
if(prevBrickCol != ballBrickCol) {
Expand Down Expand Up @@ -203,6 +229,7 @@ class Ball{
this.velocityX += inc;
}


if( this.velocityY < 0){
this.velocityY -= inc;
}
Expand Down
8 changes: 5 additions & 3 deletions js/powerup.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,17 @@ class Powerup{
}
if(this.name == "stickyBall"){
stickyBall = true;
setTimeout(function(){stickyBall = false;},20000);

setTimeout(function(){stickyBall = false;},16000);
}
if(this.name == "redBall"){
redBall = true;
setTimeout(function(){redBall = false;},20000);
setTimeout(function(){redBall = false;},16000);
}
if(this.name == "cannon"){
cannon = true;
setTimeout(function(){cannon = false;},20000);
setTimeout(function(){cannon = false;},16000);

}
if(this.name == "multiBall"){
multiBall = true;
Expand Down
Loading