class SoundDecorator(FrameDecorator): def __init__(self, parent_component=NullComponent(), sound_file_path=''): self.sound_file_path = sound_file_path self.parent = parent_component self.sound = Sound(sound_file_path) self.start_time = 0 def get_parent(self): return self.parent def set_parent(self, new_parent): self.parent = new_parent def get_landmarks(self): self.parent.get_landmarks() def get_image(self): self.play() return self.parent.get_image() def play(self): if not self.is_playing(): self.start_time = time() self.sound.play() def is_playing(self): now = time() return self.sound.get_length() > now - self.start_time def stop(self): self.sound.stop() self.start_time = 0 def copy(self): return SoundDecorator(parent_component=self.parent.copy(), sound_file_path=self.sound_file_path)
class Player(Spaceship, EventHandler): def __init__(self): super().__init__(image_path='assets/spaceship_1_normal.png') self.rocket_sound = Sound('assets/rocket.wav') self.shoot_sound = Sound('assets/player_shoot.wav') def handle(self, event: pygame.event.Event): if event.type == locals.KEYDOWN: if event.key == locals.K_RIGHT: self.move_x = self.MOVE_STEP elif event.key == locals.K_LEFT: self.move_x = -self.MOVE_STEP elif event.key == locals.K_UP: self.move_y = -self.MOVE_Y_STEP self.load_image('assets/spaceship_1_rocket.png') self.rocket_sound.play(-1) elif event.key == locals.K_DOWN: self.move_y = self.MOVE_STEP if event.type == locals.KEYUP: if event.key in (locals.K_LEFT, locals.K_RIGHT): self.move_x = 0 elif event.key == locals.K_SPACE: self.shoot() self.shoot_sound.play() elif event.key in (locals.K_UP, locals.K_DOWN): self.move_y = 0 self.load_image('assets/spaceship_1_normal.png') self.rocket_sound.stop()
class SplashScreen(GameState): def __init__(self): super(SplashScreen, self).__init__() self.font = pygame.font.Font(MAIN_TITLE_FONT[0], 54) self.title = self.font.render(GAME_TITLE, True, (229, 22, 22)) self.title_rect = self.title.get_rect(x=(SCREEN_SIZE[0] / 2) - 220, y=80) self.persist["screen_color"] = "black" self.next_state = "GAMEPLAY" self.menu = Menu([ Button("Start", ((SCREEN_SIZE[0] / 2) - 125, 300, 250, 40)), Button("Credits", ((SCREEN_SIZE[0] / 2) - 125, 350, 250, 40)) ]) self.sound = Sound("assets/sound/MainTheme.wav") self.sound.play() def startup(self, persistent): self.sound.play() self.menu.select_option(0) def get_event(self, event): if event.type == pygame.QUIT: self.quit = True elif event.type == pygame.KEYDOWN: if event.key == pygame.K_UP: self.menu.select_option(-1) elif event.key == pygame.K_DOWN: self.menu.select_option(1) elif event.key == pygame.K_RETURN: self.next_state = "GAMEPLAY" if self.menu.selected_option == 0 else "CREDITS" self.persist["selected_option"] = self.menu.selected_option self.done = True self.sound.stop() def draw(self, surface): surface.fill(Color("black")) background = pygame.image.load("assets/images/nave.png").convert() background.set_colorkey((255, 255, 255)) surface.blit(background, [(SCREEN_SIZE[0] / 2) - 250, (SCREEN_SIZE[1] / 2) - 140]) surface.blit(self.title, self.title_rect) self.menu.draw(surface) def update(self, surface): self.menu.update()
class SoundEffect: """Class wrapping ``pygame.mixer.Sound`` with the ability to enable/disable sound globally Use this instead of ``pygame.mixer.Sound``. The interface is fully transparent. """ def __init__(self, source, ui_config): self._ui_config = ui_config if ui_config.sound_on: self.sound = Sound(source) def play(self, loops=0, maxtime=0, fade_ms=0): if self._ui_config: self.sound.play(loops, maxtime, fade_ms) def stop(self): if self._ui_config: self.sound.stop() def fadeout(self, time): if self._ui_config: self.sound.fadeout(time) def set_volume(self, value): if self._ui_config: self.sound.set_volume(value) def get_volume(self): if self._ui_config: return self.sound.get_volume() def get_num_channels(self): if self._ui_config: return self.sound.get_num_channels() def get_length(self): if self._ui_config: return self.get_length() def get_raw(self): if self._ui_config: return self.sound.get_raw()
class Sound: """Class wrapping ``pygame.mixer.Sound`` with the ability to enable/disable sound globally Use this instead of ``pygame.mixer.Sound``. The interface is fully transparent. """ def __init__(self, source): if config.SOUND: self.sound = OldSound(source) def play(self, loops=0, maxtime=0, fade_ms=0): if config.SOUND: self.sound.play(loops, maxtime, fade_ms) def stop(self): if config.SOUND: self.sound.stop() def fadeout(self, time): if config.SOUND: self.sound.fadeout(time) def set_volume(self, value): if config.SOUND: self.sound.set_volume(value) def get_volume(self): if config.SOUND: return self.sound.get_volume() def get_num_channels(self): if config.SOUND: return self.sound.get_num_channels() def get_length(self): if config.SOUND: return self.get_length() def get_raw(self): if config.SOUND: return self.sound.get_raw()
def Play(sound_file): if Debug_mode: print("playing song") mixer_init = False while not mixer_init: try: if Debug_mode: print("attempting to init mixer") pygame.mixer.init() if Debug_mode: print("mixer init complete") mixer_init = True except: if Debug_mode: print("Waiting for mixer") time.sleep(10) continue pygame.mixer.init() sound = Sound(sound_file) sound.play() if Debug_mode: print("waiting for song") while pygame.mixer.get_busy(): if button.is_pressed: if Debug_mode: print("Button! Stopping Sound!") if button.is_pressed: if Debug_mode: print("button was pressed after stop - wating") button.wait_for_release() break continue if Debug_mode: print("stopping current sound") sound.stop() pygame.mixer.quit()
class SoundDecorator(FrameDecorator): def __init__(self, parent_component=NullComponent(), sound_file_path=''): self.sound_file_path = sound_file_path self.parent = parent_component self.sound = Sound(sound_file_path) self.start_time = 0 def get_parent(self): return self.parent def set_parent(self, new_parent): self.parent = new_parent def get_landmarks(self): self.parent.get_landmarks() def get_image(self): self.play() return self.parent.get_image() def play(self): if not self.is_playing(): self.start_time = time() self.sound.play() def is_playing(self): now = time() return self.sound.get_length() > now - self.start_time def stop(self): self.sound.stop() self.start_time = 0 def copy(self): return SoundDecorator(parent_component=self.parent.copy(), sound_file_path=self.sound_file_path)
def stopsound(self, sound: mixer.Sound): sound.stop()
mymatrix[tem[0]][tem[1]]=0 cnt-=1 player=3-player if ai==player: tem=premymatrix[cnt-1] del premymatrix[cnt-1] #print(premymatrix) mymatrix[tem[0]][tem[1]]=0 cnt-=1 player=3-player # premymatrix=premymatrix[1:cnt-1] continue if myevent.type == KEYDOWN: if on == 1: BGM.stop() on=0 else : BGM.play() on=1 if myevent.type == MOUSEBUTTONDOWN and flag>0: initail() continue if myevent.type == QUIT: initail() quit() exit() if tx >=0 and tx < num_line and ty>=0 or ty < num_raw: if myevent.type == MOUSEBUTTONDOWN and mymatrix[ty][tx]==0: sound.play() #sleep(0.1)
class Sound(object): """ todo is to wrap all the channel methods so they only work on the sound. This could happen either by checking if the sound is playing on the channel or possibly by calling methods on the sound itself. mixer documentation: https://www.pygame.org/docs/ref/mixer.html This class ads support for 3D positioning. Just pass the position of the sound in a tuple of (x,y) coordinates after the path of the file. """ def __init__(self, filename, position=None, single_channel=True): self.name = filename self.pos = position # should be a tuple (x, y) self.channel = None self.paused = False self.playing = False self.stopped = False # this is to tell a callback if the sound was stopped by a stop function or not. self.single_channel = single_channel self.callback = lambda e: None # the callback is passed this object as an argument and is triggered at the end of the sound self._id = "sound-%s-%s" % (self.name, id(self)) try: self.sound = Mixer_sound(filename) except: raise Exception("Unable to open file %r" % filename) def play(self, loops=0, maxtime=0, fade_ms=0): self.playing = True self.stopped = False if not self.channel or ( (not self.single_channel or self.channel.get_sound() != self.sound) and self.channel.get_busy()): self.channel = find_channel() or self.channel self.channel.play(self.sound, loops, maxtime, fade_ms) if self.pos: playing_sounds.append(self) self.set_volume() event_queue.schedule( function=self.check_if_finished, repeats=-1, delay=0, name=self._id ) # this uses the channel.get_busy to figure out if the sound has finished playing. # event_queue.schedule(function=self.finish, repeats=1, delay=self.get_length()-0.09, name=self._id) # This does the same as above, but uses the length of the sound to schedule an end event. The problem with this is that if one pauses the sound, the event still runs. The pro is that the end event can be faster than the actual sound. def get_volume(self): return self.channel.get_volume() def move_pos(self, x=0, y=0): cx, cy = self.pos self.set_pos(cx + x, cy + y) return self.pos def set_pos(self, x, y): self.pos = (float(x), float(y)) if (self.channel): self.channel.set_volume(*position.stereo(*self.pos)) def get_pos(self): return self.pos def get_length(self): return self.sound.get_length() def toggle_pause(self): """This function can be called to pause and unpause a sound without the script needing to handle the check for paused and unpaused. If the sound is paused when this function is called, then the sound is unpaused and if the sound is playing when this function is called, then the sound is paused. It's very good for buttons to play and pause sounds.""" if not self.channel or not self.playing: self.play() elif self.paused: self.unpause() else: self.pause() def unpause(self): if not self.channel: return False self.channel.unpause() self.paused = False def is_paused(self): return self.paused def pause(self): if not self.channel: return False self.channel.pause() self.paused = True def stop(self): """This stops the channel from playing.""" event_queue.unschedule(self._id) if self in playing_sounds: playing_sounds.remove(self) self.playing = False self.paused = False self.stopped = True self.unpause() if self.channel: self.channel.stop() self.finish() def stop_sound(self): """This stops the sound object from playing rather than the channel""" self.sound.stop() self.unpaws() self.playing = False mixer_queue.remove(self.channel) if self in playing_sounds: playing_sounds.remove(self) def get_busy(self): """Returns if the channel is active. This is used for triggering the callback""" if self.channel: return self.channel.get_busy() return False def check_if_finished(self): """This runs every tick to see if the channel is done. if it is done, then it runs the finish method and removes itself from the event_queue.""" if not self.get_busy(): self.finish() event_queue.unschedule(self._id) def toggle_playing(self): if self.playing: self.stop() else: self.play() def set_volume(self, volume=1, right=None): """Sets the volume if there is a channel. If there is a position, then volume is adjusted to be that position. If no arguments are passed, then it will update the volume to be the current pos, or set volume back to 1.""" if not self.channel: return 0 if volume > 1: volume = 1 elif volume <= 0: self.channel.set_volume(0) return 0 if not self.pos and not right: self.channel.set_volume(volume) elif right: self.channel.set_volume(volume, right) else: x, y = self.pos if x == 0 and y == 0: self.channel.set_volume(volume) return 0 self.channel.set_volume(*position.stereo(x / volume, y / volume)) def finish(self): self.playing = False self.paused = False self.callback(self)
pattern[x] = '1' patterns.append(''.join(pattern)) return patterns while True: val = fsr.norm(fsr.get(), 0, 16) pot_val = pot.norm(pot.get(), 0.01, 1) val = int(val / pot_val) if val > 16: val = 16 print val drums.play(-1) if val > 0: drums.stop() pattern = to_pattern(val) show.run(pattern, 0.1) if val < 8: lose.play() elif val < 12: win1.play() else: win2.play() time.sleep(3) show.off() time.sleep(0.25)
character_group = pygame.sprite.Group() character_group.add(player) all_sprite_list.add(player) #=========================================================================================================== rodando = True frame = 6 numero = 0 forro = False easteregg = 0 while rodando: for event in pygame.event.get(): # Verifica se o evento atual é QUIT (janela fechou). if event.type == QUIT: ambiente.stop() musica_inicial.stop() musica_selecao.stop() musica_história.stop() djavu.stop() darkness.stop() orgao.stop() rodando = False if event.type == pygame.KEYDOWN: pressed_keys = pygame.key.get_pressed() if pressed_keys[K_UP]: player.velocidade(0, -3) elif pressed_keys[K_DOWN]: player.velocidade(0, 3) elif pressed_keys[K_RIGHT]: player.velocidade(3, 0)
class Rocket: def __init__(self, obj_file, gravity, maximum_speed, maximum_acceleration, maximum_roll_rate, controls, blaster_list, blaster_color): self.gravity=gravity self.maximum_speed=maximum_speed self.maximum_acceleration=maximum_acceleration self.maximum_roll_rate=maximum_roll_rate self.controls=controls self.blaster_list=blaster_list self.blaster_color=blaster_color self.angle=0.0 self.model=OBJ(config.basedir+"/assets", obj_file) self.position=Vector2D(0.0,0.0) self.velocity=Vector2D(0.0,0.0) self.bounding_box=BoundingPolygon( (Vector2D(-1.0, 1.0), Vector2D(1.0, 1.0), Vector2D(1.0, -1.0), Vector2D(0.0, -2.0), Vector2D(-1.0, -1.0)) ) self.weight=1.0 self.beam=Beam() self.plume=Plume() self.blaster_sound=Sound(config.basedir+"/assets/Laser_Shoot_2.wav") self.engine_sound=Sound(config.basedir+"/assets/engine.wav") self.engine_sound.set_volume(0.075) self.fire_counter=3 @gl_utilities.sprites_configuration def _draw_sprites(self): self.beam.draw() self.plume.draw() @gl_utilities.shader_configuration(config.basedir+"/shaders/vertex.txt", config.basedir+"/shaders/fragment.txt") def _draw_shader(self): glPushMatrix() glRotate(self.angle,0.0,0.0,1.0) glRotate(90.0,-1.0,0.0,0.0) glCallList(self.model.gl_list) glPopMatrix() def draw(self): glPushMatrix() glTranslate(-self.position.x, -self.position.y, 0.0) self._draw_sprites() self._draw_shader() glPopMatrix() # _draw_bounding_box(self.bounding_box) def _fire(self): # angle, position, blaster_color, blaster_list): direction=Vector2D(math.sin(math.radians(self.angle)), -math.cos(math.radians(self.angle))) self.blaster_list.append(Blaster(self.blaster_color, self.position+2.001*direction, direction)) def update(self,clock): seconds_passed=clock.get_time()/1000.0 self.angle += (self.maximum_roll_rate* self.controls.get_rotate()* seconds_passed) if 0 < self.controls.get_throttle(): if self.plume.is_off(): self.plume.on() self.engine_sound.play() self.plume.throttle=self.controls.get_throttle() thrust=self.maximum_acceleration*seconds_passed*self.plume.throttle accel=Vector2D(math.sin(math.radians(self.angle))*thrust, -math.cos(math.radians(self.angle))*thrust) self.velocity += accel elif self.controls.get_throttle() <= 0 and self.plume.is_on(): self.plume.off() self.engine_sound.stop() self.velocity += self.gravity*seconds_passed speed = self.velocity.length() if self.maximum_speed < speed: self.velocity *= self.maximum_speed/speed self.position += self.velocity*seconds_passed self.bounding_box.position=self.position self.bounding_box.angle=self.angle self.bounding_box.update() if self.controls.get_beam_activated() and self.beam.is_off(): tmp_beam_angle = self.controls.get_beam_angle() if tmp_beam_angle is None: self.beam.angle = self.angle + 90 else: self.beam.angle = math.degrees(tmp_beam_angle) self.beam.on() elif not self.controls.get_beam_activated(): self.beam.off() if self.controls.fire() or (0 < self.fire_counter < 3) : if 0 < self.fire_counter: self.blaster_sound.play() self._fire() self.fire_counter -= 1 else: self.fire_counter=3 self.beam.update(clock) self.plume.update(clock) self.plume.angle = self.angle if self.beam.is_on() and not self.beam.is_extending(): self.beam.off()
class Audio(GameChild): current_channel = None paused = False muted = False def __init__(self, game): GameChild.__init__(self, game) self.load_fx() self.subscribe_to(self.get_custom_event_id(), self.mute) def load_fx(self): fx = {} if self.get_configuration().has_option("audio", "sfx-path"): root = self.get_resource("audio", "sfx-path") for name in listdir(root): fx[name.split(".")[0]] = Sound(join(root, name)) self.fx = fx def mute(self, event): if self.is_command(event, "mute"): self.muted = not self.muted self.set_volume() def set_volume(self): volume = int(not self.muted) music.set_volume(volume) if self.current_channel: self.current_channel.set_volume(volume) def play_bgm(self, path, stream=False): self.stop_current_channel() if stream: music.load(path) music.play(-1) else: self.current_channel = Sound(path).play(-1) self.set_volume() def stop_current_channel(self): music.stop() if self.current_channel: self.current_channel.stop() self.current_channel = None self.paused = False def play_fx(self, name): if not self.muted: self.fx[name].play() def pause(self): channel = self.current_channel paused = self.paused if paused: music.unpause() if channel: channel.unpause() else: music.pause() if channel: channel.pause() self.paused = not paused
class Gameplay(GameState): def __init__(self): super(Gameplay, self).__init__() self.game_over = False self.game_paused = False self.level_completed = False self.player = Player(INITIAL_POSITION) self.missiles = Group() self._100pts_asteroids = pygame.sprite.Group() self._500pts_asteroids = pygame.sprite.Group() self.asteroids = pygame.sprite.Group() self.asteroids.add(self._100pts_asteroids) self.asteroids.add(self._500pts_asteroids) self.explosions_group = Group() self.player_hits_group = Group() self.sound = Sound("assets/sound/FranticLevel.wav") self.level_complete_sound = Sound("assets/sound/HappyLevel.wav") self.game_over_sound = Sound("assets/sound/oops.wav") def startup(self, persistent): self.persist = persistent color = self.persist["screen_color"] self.screen_color = pygame.Color(color) # 100 Points asteroids self._100pts_asteroids.add([Asteroid100Points() for i in range(0, randint(1, 40))]) self.asteroids.add(self._100pts_asteroids) # 200 Points asteroids self._500pts_asteroids.add([Asteroid500Points() for i in range(0, randint(1, 10))]) self.asteroids.add(self._500pts_asteroids) self.sound.play(loops = -1) def get_event(self, event): if event.type == pygame.QUIT: self.quit = True elif event.type == pygame.MOUSEBUTTONDOWN: missile = self.player.shot(screen) self.missiles.add(missile) elif event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: self.game_paused = False if self.game_paused == True else True def update(self, dt): if not self.game_paused: # Asteroid hit by missile for m in self.missiles.sprites(): collided_asteroids = spritecollide(m, self.asteroids, True) for collided_asteroid in collided_asteroids: if not self.game_over: self.player.score += collided_asteroid.points # Explosion explosion = AsteroidExplosion(collided_asteroid.rect) self.explosions_group.add(explosion) explosion.sound.play() # Remove both asteroid and missile collided_asteroid.kill() m.kill() if len(self.asteroids.sprites()) == 0: self.level_completed = True # Ship hit by asteroid collided_asteroids = spritecollide(self.player, self.asteroids, True) if len(collided_asteroids) > 0: self.player_hits_group.add(self.player.hit()) if not self.game_over: collided_points = map((lambda a: a.points / 20), collided_asteroids) self.player.lifes -= reduce((lambda x, y: x + y), collided_points, 0) if self.player.lifes <= 0: self.game_over = True # Sprites and groups update self.player.update() self.asteroids.update() self.missiles.update() self.explosions_group.update() self.player_hits_group.update() def draw(self, surface): # Set background surface.fill(self.screen_color) background = pygame.image.load("assets/images/saturn.jpg").convert() surface.blit(background, [0, 0]) # Draw player self.player.position = pygame.mouse.get_pos() surface.blit(self.player.image, self.player.rect) # Draw asteroids self.asteroids.draw(surface) self.missiles.draw(surface) self.explosions_group.draw(surface) self.player_hits_group.draw(surface) # Draw title bar pygame.draw.rect(surface, Color("black"), [0, 0, SCREEN_SIZE[0], 50]) # Blit Title title_font = pygame.font.Font(MAIN_TITLE_FONT[0], 28) title = title_font.render(GAME_TITLE, True, Color("white")) surface.blit(title, [(SCREEN_SIZE[0] / 2) - 100, 10]) # Draw the title bar self.draw_title_bar(surface) # Draw Game Paused if self.game_paused and not (self.level_completed or self.game_over): self.draw_game_paused(surface) # Draw Level Completed if self.level_completed and not self.game_over: self.draw_level_complete(surface) self.sound.stop() self.level_complete_sound.play() # Draw Game Over if applicable if self.game_over: self.draw_game_over(surface) self.sound.stop() self.game_over_sound.play() def draw_title_bar(self, surface): sub_title_font = pygame.font.Font(SUB_TITLE_FONT[0], 18) score = sub_title_font.render("Score: " + str(self.player.score), True, Color("white")) lifes = sub_title_font.render("Lifes: ", True, Color("white")) surface.blit(score, [20, 20]) surface.blit(lifes, [SCREEN_SIZE[0] - 150, 20]) life_img = pygame.image.load("assets/images/life.png").convert() for life in range(0, self.player.lifes / 25): surface.blit(life_img, [(SCREEN_SIZE[0] - 80) + (life * 20), 25]) def draw_game_over(self, surface): text_font = pygame.font.Font(SUB_TITLE_FONT[0], 70) game_over_text = text_font.render("GAME OVER", True, Color("red")) surface.blit(game_over_text, [(SCREEN_SIZE[0] / 2) - 160, (SCREEN_SIZE[1] / 2) - 30]) def draw_level_complete(self, surface): text_font = pygame.font.Font(SUB_TITLE_FONT[0], 40) game_over_text = text_font.render("Level Completed", True, Color("white")) surface.blit(game_over_text, [(SCREEN_SIZE[0] / 2) - 150, (SCREEN_SIZE[1] / 2) - 20]) def draw_game_paused(self, surface): text_font = pygame.font.Font(SUB_TITLE_FONT[0], 40) game_over_text = text_font.render("Paused", True, Color("white")) surface.blit(game_over_text, [(SCREEN_SIZE[0] / 2) - 100, (SCREEN_SIZE[1] / 2) - 20])
class Carrier(Sprite): def __init__(self, capacity=500): Sprite.__init__(self, None) self.capacity = capacity self.cargos = createCargoArray() self.setRotation(0) self.setSpeed(0) self.accelerating = False self.decelerating = False self.rotating_left = False self.rotating_right = False self.thrusters_sound = Sound("assets/sounds/thrusters.ogg") # Set rotation in degrees, where 0 is heading up: def setRotation(self, rotation): self.image = self.getRotationHullImage(rotation) self.rockets_image = self.getRotationThrustersImage(rotation) self.rotation = rotation def getRotationHullImage(self, rot): path = str(rot % 360) path = path.zfill(4) path = "assets/carrier_big/hull/" + path + ".png" image = assets.loadImage(path) return image def getRotationThrustersImage(self, rot): thruster_path = str(rot % 360) thruster_path = thruster_path.zfill(4) thruster_path = "assets/carrier_big/thrusters/" + thruster_path + ".png" thruster_image = assets.loadImage(thruster_path) return thruster_image def getImages(self): images = [] for rot in range(0, 360): image = self.getRotationHullImage(rot) images.append(image) return images def draw(self): Sprite.draw(self) if self.accelerating: loc = globvars.viewport.project(self.position) loc.x = loc.x - self.image.get_width() / 2.0 loc.y = loc.y - self.image.get_height() / 2.0 globvars.surface.blit(self.rockets_image, (loc.x, loc.y)) def getRotation(self): return self.rotation def setSpeed(self, speed): if speed >= 0: self.speed = speed else: self.speed = 0 def getSpeed(self): return self.speed def setRockets(self, state): self.rockets_visible = state def setRotatingLeft(self, rotating): self.rotating_left = rotating def setRotatingRight(self, rotating): self.rotating_right = rotating def setAccelerating(self, acc): self.accelerating = acc if acc: self.thrusters_sound.play(-1) else: self.thrusters_sound.stop() def setDecelerating(self, dec): self.decelerating = dec if dec: self.thrusters_sound.play(-1) else: self.thrusters_sound.stop() def update(self, clock): if self.rotating_left: rot = self.getRotation() rot -= 1 self.setRotation(rot) if self.rotating_right: rot = self.getRotation() rot += 1 self.setRotation(rot) if self.accelerating: speed = self.getSpeed() speed += 0.2 self.setSpeed(speed) if self.decelerating: speed = self.getSpeed() speed -= 0.2 self.setSpeed(speed) rot = self.getRotation() fwd_vec = Vector2(0, -1) fwd_vec.rotate(rot) fwd_vec *= self.speed self.position += fwd_vec def getDescription(self): return "" def getPrice(self): return 0 def clone(self): pass def getType(self): return ""