From 3f7ae0846aee0b2db1e8b50a2395ec8a9ac9ec8a Mon Sep 17 00:00:00 2001 From: Justyna Ilczuk Date: Thu, 27 Dec 2012 12:29:28 +0100 Subject: [PATCH] Modify width of the beam if you like ;) --- rutherford.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/rutherford.py b/rutherford.py index 917e41e..60230c6 100644 --- a/rutherford.py +++ b/rutherford.py @@ -77,6 +77,14 @@ def main(): simulation_running = False else: simulation_running = True + elif event.key == K_COMMA: + universe.settings.beam_width -= 5 + if(universe.settings.beam_width < 5): + universe.settings.beam_width = 5 + elif event.key == K_PERIOD: + universe.settings.beam_width += 5 + + print "Pygame thread exited." @@ -123,8 +131,13 @@ class Screen: 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 for x in range(0, 39, 2): pygame.draw.aaline(self.window, BLACK, (X_SCREEN_BORDER*x/40, y), (X_SCREEN_BORDER*(x+1)/40, y), 4) + 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) + 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) @@ -201,6 +214,7 @@ class SimulationSettings: self.instructions = [ "Instructions:", "To change speed, use right and left arrow keys", "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"]