Skip to content

Commit 517dd1a

Browse files
committed
Demonstration: basic solar system
1 circulating moon around 1 planet circulating a star
1 parent bc7a0f1 commit 517dd1a

File tree

6 files changed

+35
-14
lines changed

6 files changed

+35
-14
lines changed

UniversalOperator.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
caption=(__file__.split('/')[-1]), resizable=True, vsync=False
99
)
1010

11-
b1 = celestrial_body(50, [30,30,30], [0,255,0], 1, radius=4)
12-
b2 = celestrial_body(100, [15,-15,0], [255,0,0], 0, radius=8)
13-
b3 = celestrial_body(50, [-30,-30,-30], [0,0,255], 2, radius=3)
14-
b4 = celestrial_body(50000, [-50,-50,-50], [0,0,255], 2, radius=10)
11+
# basic solar system
12+
star = celestrial_body(500, [0,0,0], [255,0,0], 0, radius=20)
13+
planet = celestrial_body(1, [200,1,1], [0,255,0], 1, radius=8)
14+
moon = celestrial_body(0.0001, [200,31,11], [0,0,255], 2, radius=5)
1515

16-
# b1.setVelocity([-1,1,1])
16+
planet.setVelocity([0,0,300])
17+
moon.setVelocity([0,10,150])
1718

1819
pyglet.app.run()

engine/graphical_support.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from utility.extramaths import *
66
from math import *
77

8-
def draw_axis(batch:graphics.Batch, rotation:str, color:tuple, color2:tuple=None, axis_length:float=25.0, tip_size:float=None):
8+
def draw_axis(batch:graphics.Batch, rotation:str, color:tuple, color2:tuple=None, axis_length:float=100.0, tip_size:float=None):
99
if not tip_size:
1010
tip_size = axis_length/50
1111
arrow_base = axis_length-(tip_size*3)

engine/physics.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def getForceVectorTo(self, towards_body, arrow_mode:bool = True):
6565
if arrow_mode:
6666
dy = sin(ay) * (
6767
self.radius
68-
+ (force / self.mass) * 1000000000000
68+
+ (force / self.mass)**(1/2) * 100000000
6969
# + distance * 0.1
7070
)
7171
else:
@@ -139,12 +139,14 @@ class cosmos:
139139
objects = []
140140
play_speed = 1
141141
vectors = []
142+
time = 0
142143

143144
obj_combinations = list(combinations(objects, 2))
144145

145146
@classmethod
146147
def update(cls, dt):
147148
tdt = cls.play_speed * dt
149+
cls.time += tdt
148150

149151
for body in cls.objects:
150152
if body.velocity != [0,0,0]:

framework/console_handler.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from concurrent import futures
2+
from concurrent.futures import ThreadPoolExecutor
3+
4+
executor = ThreadPoolExecutor(max_workers=3)
5+
6+
def get_input():
7+
return input()
8+
9+
def activation(future):
10+
result = future.result()
11+
print('USER SAID ' + str(result))
12+
13+
while True:
14+
executor.submit(get_input).add_done_callback(activation)

framework/user_input.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ def __init__(self,pos=(0,0,0)):
88
self.cam_update()
99
self.dx,self.dy = 0,0
1010

11-
def debug(self):
12-
pass
13-
1411
def cam_rotate(self,dx,dy):
1512
self.rot[0]+=dy
1613
self.rot[1]-=dx

framework/window.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
from engine.graphics import Model
88
from engine.physics import cosmos
99

10-
import datetime
1110
import platform
11+
from math import sqrt
1212

1313
userScreen = Display().get_default_screen()
1414
screenWidth, screenHeight = userScreen.width, userScreen.height
@@ -41,14 +41,14 @@ def __init__(self, *args, **kwargs):
4141
glClearColor(0.04, 0.07, 0.17, 1)
4242
glEnable(GL_DEPTH_TEST)
4343
# glEnable(GL_CULL_FACE)
44-
glPointSize(20)
44+
# glPointSize(20)
4545
glEnable(GL_LINE_SMOOTH)
4646

4747
self.set_minimum_size(int(screenWidth*0.4), int(screenHeight*0.4))
4848

4949
self.keydowns = []
5050
self.model = Model()
51-
self.user = user(pos=(25,20,50))
51+
self.user = user(pos=(175,125,200))
5252

5353
self.updating = True
5454
if self.updating == True:
@@ -63,8 +63,15 @@ def on_key_press(self,KEY,MOD):
6363
pyglet.clock.unschedule(cosmos.update)
6464
self.updating = False
6565

66+
if KEY == key.F1:
67+
print('POSITION: ' + str(self.user.pos))
68+
print('VIEW ANGLE: ' + str(self.user.rot))
69+
print('DISTANCE FROM ORIGIN: ' + str(
70+
sqrt(self.user.pos[0]**2 + self.user.pos[1]**2 + self.user.pos[2]**2)
71+
))
72+
73+
6674
if KEY == key.Q: self.close()
67-
if KEY == key.FUNCTION: self.user.debug()
6875

6976
# delta = 0.25
7077
# if KEY == key.W:

0 commit comments

Comments
 (0)