MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / check_lose

Function check_lose

examples/space_invaders/space_invaders.py:485–499  ·  view source on GitHub ↗

Return the number of army glyphs either colliding with the player or hitting the bottom of the screen. The player loses if this is non-zero.

(session, state)

Source from the content-addressed store, hash-verified

483
484
485def check_lose(session, state):
486 """Return the number of army glyphs either colliding
487 with the player or hitting the bottom of the screen.
488
489 The player loses if this is non-zero."""
490
491 player = state["player"]
492 return (
493 session.query(GlyphCoordinate)
494 .join(GlyphCoordinate.glyph.of_type(ArmyGlyph))
495 .filter(
496 GlyphCoordinate.intersects(player) | GlyphCoordinate.bottom_bound
497 )
498 .count()
499 )
500
501
502def render_message(session, window, msg, x, y):

Callers 1

update_stateFunction · 0.85

Calls 6

countMethod · 0.45
filterMethod · 0.45
joinMethod · 0.45
queryMethod · 0.45
of_typeMethod · 0.45
intersectsMethod · 0.45

Tested by

no test coverage detected