Last changes.
This commit is contained in:
parent
a633722cb3
commit
f62f4c1c98
1 changed files with 12 additions and 24 deletions
|
@ -13,7 +13,7 @@ RED = (255, 0, 0)
|
|||
GREEN = (0, 150, 0)
|
||||
BLUE = (30, 30, 180)
|
||||
VERYLIGHT = (210, 210, 210)
|
||||
BLACK = (0,0,0)
|
||||
BLACK = (5,5,5)
|
||||
WHITE = (255, 255, 255)
|
||||
|
||||
PINK = (255, 62, 150)
|
||||
|
@ -26,12 +26,12 @@ ROYALBLUE = (65, 105, 225)
|
|||
|
||||
TIME_STEP = 0.01
|
||||
|
||||
K = 50000
|
||||
K = 120000
|
||||
|
||||
X_SCREEN_BORDER = 1200
|
||||
Y_SCREEN_BORDER = 800
|
||||
X_SCREEN_BORDER = 1366
|
||||
Y_SCREEN_BORDER = 768
|
||||
|
||||
INITIAL_SPEED_X = 200
|
||||
INITIAL_SPEED_X = 300
|
||||
INITIAL_SPEED_Y = 0
|
||||
INITIAL_Y = 400
|
||||
DEFAULT_OLD_X = 2 - INITIAL_SPEED_X*TIME_STEP
|
||||
|
@ -40,7 +40,7 @@ BEAM_WIDHT = 40
|
|||
|
||||
def main():
|
||||
#create the screen
|
||||
window = pygame.display.set_mode((1200, 800))
|
||||
window = pygame.display.set_mode((1366, 768), FULLSCREEN)
|
||||
colors = [GRAY, VIOLET, RED, GREEN, BLUE, ROYALBLUE, BLACK, PINK, ORANGE, GREENYYELLOW, CRIMSON]
|
||||
|
||||
settings = SimulationSettings(K, TIME_STEP, INITIAL_Y, INITIAL_SPEED_X, BEAM_WIDHT, colors)
|
||||
|
@ -57,12 +57,13 @@ def main():
|
|||
universe.update_positions()
|
||||
else:
|
||||
screen.draw_static_surface()
|
||||
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
keep_running = False
|
||||
elif event.type == pygame.KEYUP:
|
||||
if event.key == K_UP :
|
||||
if event.key == K_ESCAPE:
|
||||
keep_running = False
|
||||
elif event.key == K_UP :
|
||||
universe.settings.initial_y -= 10
|
||||
elif event.key == K_DOWN:
|
||||
universe.settings.initial_y += 10
|
||||
|
@ -91,12 +92,7 @@ def main():
|
|||
elif event.key == K_PERIOD:
|
||||
universe.settings.beam_width += 5
|
||||
|
||||
|
||||
|
||||
print "Pygame thread exited."
|
||||
|
||||
|
||||
|
||||
print "Symulation is over."
|
||||
|
||||
class Screen:
|
||||
def __init__(self, window, colors, universe):
|
||||
|
@ -147,8 +143,6 @@ class Screen:
|
|||
for x in range(0, 79, 2):
|
||||
pygame.draw.aaline(self.window, RED, (X_SCREEN_BORDER*x/80, y - offset), (X_SCREEN_BORDER*(x+1)/80, y - offset), 2)
|
||||
|
||||
|
||||
|
||||
def draw_static_surface(self):
|
||||
self.window.fill(GRAYISH)
|
||||
self.draw_static_universe()
|
||||
|
@ -182,7 +176,6 @@ class Screen:
|
|||
description.append(line)
|
||||
return description
|
||||
|
||||
|
||||
def draw_surface(self):
|
||||
self.window.fill(self.color)
|
||||
self.draw_universe()
|
||||
|
@ -205,14 +198,12 @@ class Screen:
|
|||
ren = font.render(text,1,color)
|
||||
screen.blit(ren, (xx,yy))
|
||||
|
||||
|
||||
class Vector2:
|
||||
def __init__(self, x, y):
|
||||
self.x = x
|
||||
self.y = y
|
||||
|
||||
|
||||
|
||||
class Particle:
|
||||
def __init__(self, mass, position, old_position, charge, color):
|
||||
self.mass = mass
|
||||
|
@ -242,7 +233,7 @@ class SimulationSettings:
|
|||
class Universe:
|
||||
def __init__(self, settings):
|
||||
self.settings = settings
|
||||
atom1 = Particle(1000, Vector2(600,400), Vector2(600,400), 20, BLUE)
|
||||
atom1 = Particle(1000, Vector2(700,400), Vector2(700,400), 20, ORANGE)
|
||||
atom2 = Particle(1, Vector2(2,400), Vector2(2-TIME_STEP*INITIAL_SPEED_X,
|
||||
INITIAL_Y- TIME_STEP*INITIAL_SPEED_Y), 1, RED)
|
||||
|
||||
|
@ -301,8 +292,5 @@ class Universe:
|
|||
Vector2(2-self.settings.time_step*speed, y + random_offset), 1, random.choice(colors))
|
||||
self.particles.append(particle)
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
|
Loading…
Reference in a new issue