New colors and small improvements :)
parent
82999d9b94
commit
a633722cb3
|
@ -9,13 +9,20 @@ pygame.init()
|
|||
|
||||
GRAY = ( 182, 182, 182)
|
||||
VIOLET = (150, 100, 190)
|
||||
RED = (150, 0, 0)
|
||||
RED = (255, 0, 0)
|
||||
GREEN = (0, 150, 0)
|
||||
BLUE = (30, 30, 180)
|
||||
VERYLIGHT = (210, 210, 210)
|
||||
BLACK = (0,0,0)
|
||||
WHITE = (255, 255, 255)
|
||||
|
||||
PINK = (255, 62, 150)
|
||||
MAGENTA = (255, 0, 255)
|
||||
ORANGE = (255, 69, 0)
|
||||
GREENYYELLOW = (173, 255, 47)
|
||||
CRIMSON = (220, 20, 60)
|
||||
GRAYISH = (210, 210, 255)
|
||||
ROYALBLUE = (65, 105, 225)
|
||||
|
||||
TIME_STEP = 0.01
|
||||
|
||||
|
@ -29,12 +36,12 @@ INITIAL_SPEED_Y = 0
|
|||
INITIAL_Y = 400
|
||||
DEFAULT_OLD_X = 2 - INITIAL_SPEED_X*TIME_STEP
|
||||
DEFAULT_OLD_Y = INITIAL_Y - INITIAL_SPEED_Y*TIME_STEP
|
||||
BEAM_WIDHT = 20
|
||||
BEAM_WIDHT = 40
|
||||
|
||||
def main():
|
||||
#create the screen
|
||||
window = pygame.display.set_mode((1200, 800))
|
||||
colors = [GRAY, VIOLET, RED, GREEN, BLUE, VERYLIGHT, BLACK]
|
||||
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)
|
||||
#Initialize universe with some atoms
|
||||
|
@ -129,6 +136,7 @@ class Screen:
|
|||
|
||||
pygame.draw.aaline(self.window, BLUE, start_position, end_position, 4)
|
||||
pygame.draw.circle(self.window, RED, end_position, 2)
|
||||
|
||||
def draw_guide(self):
|
||||
y = self.universe.settings.initial_y
|
||||
offset = self.universe.settings.beam_width
|
||||
|
@ -146,10 +154,16 @@ class Screen:
|
|||
self.draw_static_universe()
|
||||
description_of_simulation_settings = self.prepare_settings_description(self.universe.settings)
|
||||
for i, text in enumerate(self.communicates + description_of_simulation_settings):
|
||||
self.print_text(text, 20, 20 + i*20, (0, 0, 0), 24, self.window)
|
||||
if(i == 0):
|
||||
self.print_text(text, 20, 14 + i*20, CRIMSON, 28, self.window)
|
||||
else:
|
||||
self.print_text(text, 20, 20 + i*20, BLACK, 24, self.window)
|
||||
if(self.universe.settings.show_instructions):
|
||||
for i, text in enumerate(self.universe.settings.instructions):
|
||||
self.print_text(text, 350, 20 + i*20, (0, 0, 0), 24, self.window)
|
||||
if(i == 0):
|
||||
self.print_text(text, 350, 14 + i*20, GREEN, 28, self.window)
|
||||
else:
|
||||
self.print_text(text, 350, 20 + i*20, BLACK, 24, self.window)
|
||||
pygame.display.flip()
|
||||
|
||||
def prepare_settings_description(self, settings):
|
||||
|
@ -174,10 +188,16 @@ class Screen:
|
|||
self.draw_universe()
|
||||
description_of_simulation_settings = self.prepare_settings_description(self.universe.settings)
|
||||
for i, text in enumerate(self.communicates + description_of_simulation_settings):
|
||||
self.print_text(text, 20, 20 + i*20, (0, 0, 0), 24, self.window)
|
||||
if(i == 0):
|
||||
self.print_text(text, 20, 14 + i*20, CRIMSON, 28, self.window)
|
||||
else:
|
||||
self.print_text(text, 20, 20 + i*20, BLACK, 24, self.window)
|
||||
if(self.universe.settings.show_instructions):
|
||||
for i, text in enumerate(self.universe.settings.instructions):
|
||||
self.print_text(text, 350, 20 + i*20, (0, 0, 0), 24, self.window)
|
||||
if(i == 0):
|
||||
self.print_text(text, 350, 14 + i*20, GREEN, 28, self.window)
|
||||
else:
|
||||
self.print_text(text, 350, 20 + i*20, BLACK, 24, self.window)
|
||||
pygame.display.flip()
|
||||
|
||||
def print_text(self, text,xx,yy,color,text_size, screen):
|
||||
|
@ -216,13 +236,13 @@ class SimulationSettings:
|
|||
"To change position of the beam, use up and down arrow keys",
|
||||
"To change width of the beam, use , and . keys",
|
||||
"To add particle, press space",
|
||||
"To stop/restart simulation, press enter"]
|
||||
"To pause/continue simulation, press enter"]
|
||||
|
||||
|
||||
class Universe:
|
||||
def __init__(self, settings):
|
||||
self.settings = settings
|
||||
atom1 = Particle(1000, Vector2(500,500), Vector2(500,500), 20, BLUE)
|
||||
atom1 = Particle(1000, Vector2(600,400), Vector2(600,400), 20, BLUE)
|
||||
atom2 = Particle(1, Vector2(2,400), Vector2(2-TIME_STEP*INITIAL_SPEED_X,
|
||||
INITIAL_Y- TIME_STEP*INITIAL_SPEED_Y), 1, RED)
|
||||
|
||||
|
|
Loading…
Reference in New Issue