From 6f3f78d1719c3a380b1bc1eb1b541ec18e8779aa Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Tue, 12 Oct 2021 14:53:11 +0200 Subject: [PATCH] Stuff --- app.rb | 2 +- physobj.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app.rb b/app.rb index 7f3fbc9..4fc7ed0 100755 --- a/app.rb +++ b/app.rb @@ -42,7 +42,7 @@ end window = Window.new("Physics!", 1600, 900) -planet = Planet.new("Earth", window, 0xff_aaffaa) +planet = Planet.new("Earth", window, 0xff_aaffaa, 0.0001) planet.pos = Vector[800, 450] cube = PhysCube.new("Cube", window, 8, 8) diff --git a/physobj.rb b/physobj.rb index 8af265b..5ada7ea 100644 --- a/physobj.rb +++ b/physobj.rb @@ -100,7 +100,8 @@ class Planet < PhysCube private def calculate_gravity_vector(obj) dir_vec = self.pos - obj.pos + Vector[self.width/2, self.height/2] - return (self.gravity * dir_vec)/(dir_vec.magnitude) + return dir_vec * self.gravity + # return (self.gravity * dir_vec)/(dir_vec.magnitude) end def orbit(physobjs)