This site requires JavaScript, please enable it in your browser!
Greenfoot back

Report as inappropriate.

RcCookie
RcCookie presents ...

2020/9/1

Physics and collision engine

A demo of my physics engine for Greenfoot.

DETAILED DOCUMENTATION INCLUDED!

Featuring:
- Smooth moving objects using double-vectors
- Custom colliders that are free of the form and size of the actors image and can have other geometric forms
- Physical behavior with inertia, momentum, impulse, elastic and non-elastic collisions, gravity, drag...
- Framerate-independent movement using the current fps to get a stable movement at maximum framerate

All this can easily be used for your game by simply extending from my classes. Custom coded colliders are also supported. Please credit this scenario, if you want to use it.

The classes make use of my custom packages including vectors, transforms, time delta classes and more. This is all included. Simply copy the "packages" folder into your project. Most of that is also commented!


For the online demo:
If it shows something like "HTML does not support this", simply reload the side.
The demo actually visualizes the colliders of the objects. The actual actors use the normal green foot as image. As you can see, it's not working perfectly, but still acceptable. Also, the performance is pretty good.

3352 views / 24 in the last 7 days

4 votes | 0 in the last 7 days

Tags: mouse game simulation physics demo vector collision smooth reuse

open in greenfoot
Your browser does not support the canvas tag.
Thank you very much! Your scenario helped me better understand how to do physics in java. AI is certainly cool, but not knowing how to do the simplest physics may not make a good game! I will be glad if you will continue to make such scenarios!!!
A new version of this scenario was uploaded on 2020-09-02 17:40:18 UTC Fixed objects slowing down on collisions
I also wanted to ask you a question: based on the structure of your project, I determined that this scenario was not made in Greenfoot. I think you work in JavaFX(or Android Studio), am I right?
RcCookieRcCookie

2020/9/2

Actually, it is all hand-coded purely for Greenfoot (maybe VS Code as editor sometimes ;-) ). I would guess that you said this because I use a lot of packages?
RcCookieRcCookie

2020/9/2

Btw I'm also not very "good" at physics (as you can see by objects glitching through each other), but I am happy to see that some people appreciate the work that went into this. Kinda like your AI scenario I'm trying to create basics to acutally use in other games. That's also why I use packages.
Well, I decided to try to make my physics based purely on mathematical calculations. It seems to me that some people may simply not find where the packages folder is located, and so everything is simple and clear))) I will update World of Tank 2d in a few days and there will already be this new physics.
RcCookieRcCookie

2020/9/3

Cool! Yeah, the actual finding of the packages folder is the main challenge for most people. I always try to tell them in the description a little bit.

Want to leave a comment? You must first log in.

Who likes this?

23571113 Game/maniac Roshan123 Kostya20052011