MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / move_missile

Function move_missile

examples/space_invaders/space_invaders.py:635–661  ·  view source on GitHub ↗

Update the status of the current missile, if any.

(session, window, state)

Source from the content-addressed store, hash-verified

633
634
635def 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
664def move_saucer(session, window, state):

Callers 1

update_stateFunction · 0.85

Calls 9

scoreFunction · 0.85
blankMethod · 0.80
firstMethod · 0.45
filterMethod · 0.45
joinMethod · 0.45
queryMethod · 0.45
of_typeMethod · 0.45
intersectsMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected