Checkpoint
This commit is contained in:
parent
c20f9b2578
commit
cd5300030b
8
mecha.py
8
mecha.py
@ -14,7 +14,7 @@ class Mass():
|
|||||||
self.pos = np.array(pos, dtype='float64')
|
self.pos = np.array(pos, dtype='float64')
|
||||||
self.speed = np.array(speed, dtype='float64')
|
self.speed = np.array(speed, dtype='float64')
|
||||||
self.mass = mass
|
self.mass = mass
|
||||||
self.G = 0.0000001
|
self.G = 0.000001
|
||||||
|
|
||||||
def tick(self):
|
def tick(self):
|
||||||
self.pos += self.speed
|
self.pos += self.speed
|
||||||
@ -22,9 +22,9 @@ class Mass():
|
|||||||
def ref(self,
|
def ref(self,
|
||||||
origin=np.array((0, 0), dtype='float64'),
|
origin=np.array((0, 0), dtype='float64'),
|
||||||
speed=np.array((0, 0), dtype='float64')):
|
speed=np.array((0, 0), dtype='float64')):
|
||||||
self.pos -= origin
|
#self.pos -= origin
|
||||||
self.speed -= speed
|
#self.speed -= speed
|
||||||
|
pass
|
||||||
def apply_gravity(self, elements):
|
def apply_gravity(self, elements):
|
||||||
for element in elements:
|
for element in elements:
|
||||||
d = element.pos - self.pos
|
d = element.pos - self.pos
|
||||||
|
@ -70,7 +70,7 @@ if __name__ == "__main__":
|
|||||||
tick = (time.time(), time.time(), 0)
|
tick = (time.time(), time.time(), 0)
|
||||||
screen = pygame.display.set_mode(size,
|
screen = pygame.display.set_mode(size,
|
||||||
flags=pygame.RESIZABLE)
|
flags=pygame.RESIZABLE)
|
||||||
elements = [Player(speed=(5, 0), pos=(10, -200)), Player(speed=(-5, 0), pos=(10, 200), mass = 2), Planet(mass=200)]
|
elements = [Player(speed=(5, 0), pos=(10, -200)), Player(speed=(-5, 0), pos=(10, 200), mass = 1), Planet(mass=200)]
|
||||||
reference = 1
|
reference = 1
|
||||||
joy=[1, 1]
|
joy=[1, 1]
|
||||||
while 1:
|
while 1:
|
||||||
@ -103,8 +103,9 @@ if __name__ == "__main__":
|
|||||||
elements[1].mecha.orientation=joy[0]*(-3)
|
elements[1].mecha.orientation=joy[0]*(-3)
|
||||||
for element in elements:
|
for element in elements:
|
||||||
element.mecha.apply_gravity([element.mecha for element in elements])
|
element.mecha.apply_gravity([element.mecha for element in elements])
|
||||||
|
for element in elements:
|
||||||
element.mecha.tick()
|
element.mecha.tick()
|
||||||
ori,speed=origin=elements[1].mecha.pos, origin=elements[1].mecha.speed
|
ori,speed=origin=elements[0].mecha.pos, elements[0].mecha.speed
|
||||||
for element in elements:
|
for element in elements:
|
||||||
element.mecha.ref(origin=ori, speed=speed)
|
element.mecha.ref(origin=ori, speed=speed)
|
||||||
if i < 2:
|
if i < 2:
|
||||||
|
Loading…
Reference in New Issue
Block a user