smileyface12349 / notorious-narwhals

Summer Code Jam 2021 on Python Discord - Team Notorious Narwhals
MIT License
6 stars 0 forks source link

Physics engine #7

Open smokeythemonkey opened 3 years ago

smokeythemonkey commented 3 years ago

Part of the Game Object class issue https://github.com/smileyface12349/notorious-narwhals/issues/10#issue-941502195

smileyface12349 commented 3 years ago

I think it's worth noting that all of the physics of an object will be defined by the properties of that object. There will be a single class fo both static and kinematic bodies (GameObject). The properties are all documented in the doc (although they preferably need to be documented somewhere within the project as well).

Also a very small note: 'max velocity' won't be a thing since we are ignoring air resistance. This shouldn't be an issue though as objects are unlikely to get close to terminal velocity

As for the physics engine itself, I'm not sure how this would work if it was separated from the main game loop. Maybe a separate function that's called each tick to calculate all the forces and adjust values accordingly?

smokeythemonkey commented 3 years ago

issue amended to be more clear. I was thinking along the lines of having a class for static bodies and a class for kinematics that inherits from static bodies.

the kinematics class can have a method for interaction and update which can be called in the game loop

on game init we generate the objects with their properties

smileyface12349 commented 3 years ago

So do you mean something like this for inheritance structure:

That could simplify programming to link together lots of similar objects so that seems like a decent idea

smokeythemonkey commented 3 years ago

I'll give this a go and make an initial version

smileyface12349 commented 3 years ago

Where are you going to make it? It could be in something like GameObject.update(), but then a separate function would have to handle objects interacting with each other

smokeythemonkey commented 3 years ago

Yeah, i wanna write some structured pseudo code based on what has been documented so far before I start so we can go over it. Don't wanna end up with spaghetti code!

smileyface12349 commented 3 years ago

I've mostly implemented this into GameObject, however this needs quite a bit of testing (I haven't tested it at all)