Coder Social home page Coder Social logo

collisionchallengebasketball's Introduction

CollisionChallengeBasketball

This is a code challenge scaffolding for playing with 2D Collisions and User Experience!

Play the basic game here

The App

  • Drag-and-release your mouse to sling a basketball towards the goal
  • Currently only supported on Desktop
  • "Vanilla" Javascript (no libraries at all)
  • Very minimal codebase: 200 lines of JS, and small amounts of CSS and HTML

The Challenge

  • Implement collisions for the rim and backboard of the goal
  • Detect collisions with the inner goal area
  • Show a visual message to the user that they scored! Bonus points if it's flashy and has transitions or animations.

What counts as a visual message? Display some text in the middle of the screen, shoot emojis like confetti, or animate a dancing baby! (Don't do that last one)

The Code

The areas of the code left for implementation are in main.js

  function checkRimCollisions(ballX, ballY, vel_x, vel_y) {
    //available dimensions:
    // ball_w, ball_h
    // rim_w
    // rim_front_h, rim_front_x, rim_front_y
    // rim_back_h, rim_back_x, rim_back_y

    // ball has a radius of ball_w/2
    // ballX and ballY are the bottom-left corner of the ball
    // ballX and ballY are the PAST version of the ball
    // vel_x and vel_y will be ADDED to ballX and ballY after this function

    //TODO: change vel_x and vel_y to "bounce" off of rim and backboard

    return {
        vel_x: vel_x,
        vel_y: vel_y
    }
}
function checkGoal(ballX, ballY, ballHW) {
    // available dimensions:
    // goal_w, goal_h
    // goal_x, goal_y

    //TODO: return TRUE when ball is in goal

    return false;
}
function onGoal(ballNumber) {
    //TODO: show a visual indicator the user scored
    //it's encouraged to append elements to the body and then style them in CSS
}

collisionchallengebasketball's People

Contributors

acreeser avatar acreesercorebridge avatar

Watchers

James Cloos avatar  avatar

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.