本文整理汇总了Python中ship.Ship.hit方法的典型用法代码示例。如果您正苦于以下问题:Python Ship.hit方法的具体用法?Python Ship.hit怎么用?Python Ship.hit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ship.Ship
的用法示例。
在下文中一共展示了Ship.hit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testShip
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import hit [as 别名]
def testShip(self):
ship = Ship(Coord(1, 1), Coord(1, 2))
self.assertTrue(ship.covers(Coord(1, 1)), "ship(1, 1, 1, 2).covers(1, 1)")
self.assertTrue(ship.covers(Coord(1, 2)), "ship(1, 1, 1, 2).covers(1, 2)")
self.assertFalse(ship.covers(Coord(2, 1)), "ship(1, 1, 1, 2).covers(2, 1)")
self.assertFalse(ship.covers(Coord(1, 3)), "ship(1, 1, 1, 2).covers(1, 3)")
self.assertFalse(ship.sunk())
self.assertTrue(ship.fire(Coord(1, 1)))
self.assertTrue(ship.hit(Coord(1, 1)))
self.assertFalse(ship.hit(Coord(1, 2)))
self.assertFalse(ship.sunk())
self.assertTrue(ship.fire(Coord(1, 2)))
self.assertTrue(ship.hit(Coord(1, 1)))
self.assertTrue(ship.hit(Coord(1, 2)))
self.assertTrue(ship.sunk())
示例2:
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import hit [as 别名]
gameov.play()
pygame.display.update()
else:
for wall in walls: #oslona
if pygame.sprite.spritecollide(wall,bombs,True):
wall.delete()
if pygame.sprite.spritecollide(wall,rockets,True):
wall.delete()
if wall.delt == 1:
wall.remove(walls)
for i in bombs: #jak uderzy mnie
if pygame.sprite.collide_rect(i,my_ship):
boom = True
p = my_ship.x-13,460
i.remove(bombs)
my_ship.hit()
score -= 20 * lev
sound.stop()
boom_sound.play()
for i in invaders:
if i.y > 460:
my_ship.life = 0
score = 0
if pygame.sprite.collide_rect(i,my_ship):
my_ship.life = 0
score = 0
if pygame.sprite.spritecollide(i, walls, True):
i.remove(invaders)
boom = True
p = i.x-13, i.y-13
score -= 10 * lev