Fix mass function use

This commit is contained in:
Quinn
2021-12-26 22:10:14 -08:00
parent 936c8fe40f
commit 56942461e7
3 changed files with 8 additions and 8 deletions
+4 -4
View File
@@ -63,8 +63,8 @@ ball = {
rad = 1,
col = 7,
mass = function()
return rad
mass = function(self)
return self.rad
end,
draw = function(self)
@@ -165,8 +165,8 @@ function handle_collisions()
s_xpoint = source.pos - source.vel * rewind
t_xpoint = target.pos - target.vel * rewind
until rewind > 1 or (s_xpoint - t_xpoint):mag() >= source.rad + target.rad
local s_newvel = collision_vel(s_xpoint, source.vel, t_xpoint, target.vel, source.mass(), target.mass())
local t_newvel = collision_vel(t_xpoint, target.vel, s_xpoint, source.vel, target.mass(), source.mass())
local s_newvel = collision_vel(s_xpoint, source.vel, t_xpoint, target.vel, source:mass(), target:mass())
local t_newvel = collision_vel(t_xpoint, target.vel, s_xpoint, source.vel, target:mass(), source:mass())
source.pos = s_xpoint + source.vel * rewind
target.pos = t_xpoint + target.vel * rewind
source.vel = s_newvel