diff --git a/bomb.py b/bomb.py index e915765..b2d8bce 100644 --- a/bomb.py +++ b/bomb.py @@ -29,8 +29,8 @@ class Bomb: self.sprites.append(button) def getevents(self): - for event in self.pygame.event.get(): # User did something - if event.type == self.pygame.QUIT: # If user clicked close + for event in self.pygame.event.get(): + if event.type == self.pygame.QUIT: return False elif event.type == self.pygame.MOUSEBUTTONUP: pos = self.pygame.mouse.get_pos() diff --git a/main.py b/main.py index 7a40e87..30bb265 100644 --- a/main.py +++ b/main.py @@ -13,13 +13,10 @@ clock = pygame.time.Clock() bomb = Bomb(pygame, screen) while True: - bomb.drawstuff() - bomb.ticktimer += clock.tick(60) bomb.beep() if bomb.getevents() == False: break -#Once we have exited the main program loop we can stop the game engine: pygame.quit() \ No newline at end of file diff --git a/tonegen.py b/tonegen.py index 5b91699..555f721 100644 --- a/tonegen.py +++ b/tonegen.py @@ -5,14 +5,12 @@ class ToneGen(): def __init__(self, pygame, freq_l, freq_r, duration=1): n_samples = int(round(duration*44100)) - #setup our numpy array to handle 16 bit ints, which is what we set our mixer to expect with "bits" up above buf = np.zeros((n_samples, 2), dtype = np.int16) max_sample = 2**(16 - 1) - 1 for s in range(n_samples): t = float(s)/44100 # time in seconds - #grab the x-coordinate of the sine wave at a given time, while constraining the sample to what our mixer is set to with "bits" buf[s][0] = int(round(max_sample*sin(2*pi*freq_l*t))) # left buf[s][1] = int(round(max_sample*0.5*sin(2*pi*freq_r*t))) # right pygame.sndarray.make_sound(buf).play()