"""
gameplay.py - top-level routine for game actions
"""

import common
import pygame
import levels
import collisions

def run():
    dirtyrects = []
    p = common.player
    # hide + move
    p.hide()
    p.move()
    # hide + move
    for x in common.shots_player+common.shots_enemy+common.enemies+common.misc_goodies+common.misc_harmful+common.misc_neutral:
        x.hide()
        x.move()

    # collisions
    collisions.check()        

    # show
    dirtyrects += p.show()
    # show
    for x in common.shots_player+common.shots_enemy+common.enemies+common.misc_goodies+common.misc_harmful+common.misc_neutral:
        dirtyrects += x.show()

    pygame.display.update(dirtyrects)
    #pygame.display.update()

    levels.nextFrame()
