GithubHelp home page GithubHelp logo

nhatphongdo / collisiondetection Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jeffthompson/collisiondetection

0.0 1.0 0.0 2.17 MB

A book and examples on collision detection

Processing 16.50% JavaScript 66.19% PHP 16.34% CSS 0.97%

collisiondetection's Introduction

Collision Detection

View the book, including interactive examples: jeffreythompson.org/collision-detection

UPDATE! This site has been getting lots of visits which is awesome. I've made some changes so it will look better on mobile devices, make navigation easier, and tried to look over everything for mistakes. If you have any problems or suggestions, please post an issue on the project repository. Thanks!

The collision of objects underlies most game experiences and user-interfaces. Baseball bats collide with balls, zombies bump into walls, and Mario lands on platforms and stomps turtles. Even something as simple as clicking a button (a rectangle) with your mouse (a point) is a collision.

This book explains the algorithms behind those collisions using basic shapes like circles, rectangles, and lines so you can implement them into your own projects.


WHAT'S COVERED HERE?

This book covers collisions between points, circles, rectangles, lines, polygons, and triangles. These examples are meant to be as readable and easily understood as possible. There are definitely faster, more efficient ways to detect these collisions, but this book is intended to be friendly and teach the principles with minimal math.

Each section includes a description of the collision algorithm and an interactive example built using processing.js.


WHAT'S NOT?

As with any book, there's a lot more useful material than could be covered here. Things that aren't discussed are mostly left out because the math gets too complicated. Three-dimensional space isn't touched on. Ellipses, which seem like they should be pretty easy, are actually very difficult.

If there's a specific collision not covered that would be helpful, please please submit an issue with a request or, better yet, submit a working example that you've built!


ISSUES?

If you find code that doesn't run correctly, an algorithm that isn't explained quite right, or a typo, please report them. Thanks for your help!


LICENSE

This book's entire contents, including the code examples and this text, is released under a Creative Commons Attribution, Non-Commercial, Share-Alike license. This means:

  1. You're welcome to use this book and the examples to make great stuff, but please cite this book somewhere in your project or its documentation.
  2. You can only use the book's text and/or code vertbatim for non-commercial projects. That means you can remix or make your own version of the book, and you can fork and create new libraries based on the code here, so long as they are not commercial projects (ie publishing a book with a publisher). I'm very happy to talk options if you have a paid gig and you'd like to use some of the materials.
  3. If you do make a project that forks or remixes this book or code-base, it must be released under this same license or a looser one. Pay it forward!

But you're free to use the ideas and code from this book inside your projects, so long as this is just a part of what you're working on. In other words: you're welcome to build a super cool game that relies on the code you've seen here, even if you're going to sell it!

If you have any questions about what you can and can't do with these examples, please get in touch.


WHAT YOU SHOULD ALREADY KNOW

This book's examples are written in Processing, a wrapper for the Java programming language. While you need only a little programming experience, you should understand how a basic Processing sketch is structured, how to use variables, how to draw shapes and get input from the mouse, and how if/else statements work. It may be helpful to understand using PVector objects to store positions, but we'll cover the basics if you haven't used them before.

At the end, we will talk about using collision in object-oriented code. Understanding object-oriented programming will not be required to use this book, but it will be helpful for using these topics in larger projects with lots of objects hitting each other.

collisiondetection's People

Contributors

jeffthompson avatar johschmitz avatar misode avatar

Watchers

 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.