sprites¶
sprites¶
AsteroidImpact game sprites including sprite-specific behaviors.
-
class
sprites.Asteroid(diameter=200, dx=4, dy=10, left=20, top=20, area=None)¶ Bases:
sprites.VirtualGameSpriteAsteroids move in straight lines, bouncing off the edges of the game play area
-
copy_from(asteroid)¶
-
update(millis)¶ Update the position and direction of the Asteroid to move, and bounce
-
-
class
sprites.BasePowerup(diameter=16, left=50, top=50, maxduration=5.0)¶ Bases:
sprites.VirtualGameSpriteBase class for power-ups so they share common expiration behavior
-
activate(cursor, asteroids, frame_outbound_triggers, *args)¶ Activate power-up because it was picked up
-
deactivate(cursor, asteroids, frame_outbound_triggers)¶ Deactivate power-up
-
update(millis, frame_outbound_triggers, cursor, asteroids)¶ Deactivate power-up if duration has expired
-
-
class
sprites.Cursor(game_bounds=<rect(0, 0, 1280, 896)>)¶ Bases:
sprites.VirtualGameSpriteThe Player’s ship is moved around using the mouse cursor
-
update(millis)¶ Move the cursor based on the mouse position
-
-
class
sprites.NonePowerup(duration=10.0)¶ Bases:
sprites.BasePowerupThis power-up has no effect except delaying the next power-up from spawning
-
class
sprites.ReactionTimePrompt(diameter=64, position_list=[[20, 20]], sound='tone440.wav', image='triangle.png', input_key='K_1', showtimes_millis=[], showtimes_trigger_counts=[], timeout_millis=5000, stay_visible=False, **kwargs_extra)¶ Bases:
sprites.VirtualGameSpriteGame element to test reaction time
-
activate_and_show()¶
-
deactivate_and_hide()¶
-
logme(logrowdetails, reactionlogger)¶
-
step_end_deactivate(logrowdetails, reactionlogger)¶
-
update(millis, logrowdetails, reactionlogger, frame_outbound_triggers, events, step_trigger_count)¶
-
-
class
sprites.ScoredTarget(diameter=32, left=20, top=20, imagefile='crystal.png', number='x', lifetime_millis_max=None)¶ Bases:
sprites.VirtualGameSpriteTargets (Crystals) don’t move, but do play a sound when collected
-
activate(life_multiplier=1)¶
-
deactivate()¶
-
pickedup()¶ Play pick up sound
-
stop_audio()¶
-
update(millis)¶
-
-
class
sprites.ShieldPowerup(diameter=32, left=80, top=80)¶ Bases:
sprites.BasePowerupWhile active, the ShieldPowerup prevents the player from dying due to collisions with asteroids.
-
activate(cursor, asteroids, frame_outbound_triggers, *args)¶ Play activation sound
-
stop_audio()¶
-
update(millis, frame_outbound_triggers, cursor, asteroids)¶ Follow cursor. Play effect end sound if due
-
-
class
sprites.SlowPowerup(diameter=32, left=100, top=100)¶ Bases:
sprites.BasePowerupWhile active, the SlowPowerup slows the asteroids to a crawl
-
activate(cursor, asteroids, frame_outbound_triggers, *args)¶ Play start sound. Slow asteroids to a crawl
-
deactivate(cursor, asteroids, frame_outbound_triggers, *args)¶ Restore normal speed of asteroids
-
stop_audio()¶
-
update(millis, frame_outbound_triggers, cursor, asteroids)¶ Play effect end sound if due
-
-
class
sprites.Target(diameter=32, left=20, top=20)¶ Bases:
sprites.VirtualGameSpriteTargets (Crystals) don’t move, but do play a sound when collected
-
pickedup()¶ Play pick up sound
-
stop_audio()¶
-
update(millis)¶
-
-
class
sprites.TextSprite(font, text, color, **kwargs)¶ Bases:
objectSprite-like object for text that helps positioning text in game coordinates, and keeping text in position when text changes.
-
draw(screen)¶ Draw text on screen
-
set_position(**kwargs)¶
-
set_text(text)¶ Set and render new text
-
-
class
sprites.VirtualGameSprite¶ Bases:
pygame.sprite.DirtySpriteSprite with higher resolution game position/size (gamerect) than on-screen position/size (rect)
-
stop_audio()¶
-
update_rect()¶
-
-
sprites.clamp_range(value, limit_low, limit_high)¶ return limit_low if value < limit_low, limit_high if value > limit_high, otherwise value
-
sprites.map_range(value, from_low, from_high, to_low, to_high)¶ return value in range [from_low, from_high] mapped to range [to_low, to_high]