Update the status of the current missile, if any.
(session, window, state)
| 633 | |
| 634 | |
| 635 | def move_missile(session, window, state): |
| 636 | """Update the status of the current missile, if any.""" |
| 637 | |
| 638 | if state["missile"] is None or state["tick"] % 2 != 0: |
| 639 | return |
| 640 | |
| 641 | missile = state["missile"] |
| 642 | |
| 643 | # locate enemy glyphs which intersect with the |
| 644 | # missile's current position; i.e. a hit |
| 645 | glyph = ( |
| 646 | session.query(GlyphCoordinate) |
| 647 | .join(GlyphCoordinate.glyph.of_type(EnemyGlyph)) |
| 648 | .filter(GlyphCoordinate.intersects(missile)) |
| 649 | .first() |
| 650 | ) |
| 651 | missile.blank(window) |
| 652 | if glyph or missile.top_bound: |
| 653 | # missile is done |
| 654 | session.delete(missile) |
| 655 | state["missile"] = None |
| 656 | if glyph: |
| 657 | # score! |
| 658 | score(session, window, state, glyph) |
| 659 | else: |
| 660 | # move missile up one character. |
| 661 | missile.y -= 1 |
| 662 | |
| 663 | |
| 664 | def move_saucer(session, window, state): |
no test coverage detected