Tweaked collision physics
This commit is contained in:
parent
1c654fcf81
commit
aa6ab1dca6
@ -75,11 +75,13 @@ class Entity(object):
|
|||||||
depth /= other.elasticity
|
depth /= other.elasticity
|
||||||
force_vec = force_dir[0]*depth/self.env.width, \
|
force_vec = force_dir[0]*depth/self.env.width, \
|
||||||
force_dir[1]*depth/self.env.height
|
force_dir[1]*depth/self.env.height
|
||||||
self.pos = self.pos[0] + force_vec[0], self.pos[1] + force_vec[1]
|
if sum([abs(f) for f in force_vec]) > 0.005:
|
||||||
if self._coll_add_pushback:
|
self.pos = self.pos[0] + force_vec[0], self.pos[1] + force_vec[1]
|
||||||
self.pos = self.pos[0] - self.env.inp[0]*self._coll_add_pushback * \
|
print('#########################')
|
||||||
self.env.speed_fac, self.pos[1] - self.env.inp[1] * \
|
if self._coll_add_pushback:
|
||||||
self._coll_add_pushback*self.env.speed_fac
|
self.pos = self.pos[0] - self.env.inp[0]*self._coll_add_pushback * \
|
||||||
|
self.env.speed_fac, self.pos[1] - self.env.inp[1] * \
|
||||||
|
self._coll_add_pushback*self.env.speed_fac
|
||||||
if self.collision_changes_speed:
|
if self.collision_changes_speed:
|
||||||
self.speed = self.speed[0] + \
|
self.speed = self.speed[0] + \
|
||||||
force_vec[0]*self.collision_elasticity/self.env.speed_fac, self.speed[1] + \
|
force_vec[0]*self.collision_elasticity/self.env.speed_fac, self.speed[1] + \
|
||||||
|
Loading…
Reference in New Issue
Block a user