本文整理汇总了Python中car.Car.render方法的典型用法代码示例。如果您正苦于以下问题:Python Car.render方法的具体用法?Python Car.render怎么用?Python Car.render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类car.Car
的用法示例。
在下文中一共展示了Car.render方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MirrorMan
# 需要导入模块: from car import Car [as 别名]
# 或者: from car.Car import render [as 别名]
class MirrorMan(gamelib.SimpleGame):
PURPLE = pygame.Color('purple')
def __init__(self):
super(MirrorMan, self).__init__('Mirror Man', MirrorMan.PURPLE)
self.gameover = False
self.win = False
self.player = Player((random.randint(50,750), 10))
self.car = Car(0, 125, 'yellow')
self.car2 = Car(800, 225, 'red')
self.car3 = Car(-100, 325, 'yellow')
self.car4 = Car(900, 425, 'red')
#self.checkcollision = CheckCollision(self.player, self.car, self.car2, self.car3, self.car4)
def init(self):
super(MirrorMan, self).init()
def update(self):
collision = CheckCollision()
if not self.gameover and not self.win:
self.car.move()
self.car2.move()
self.car3.move()
self.car4.move()
if self.is_key_pressed(K_UP):
self.player.move_down()
elif self.is_key_pressed(K_DOWN):
self.player.move_up()
elif self.is_key_pressed(K_LEFT):
self.player.move_right()
elif self.is_key_pressed(K_RIGHT):
self.player.move_left()
if collision.iamhit(self.player, self.car, self.car2, self.car3, self.car4):
self.gameover = True
def render(self, surface):
self.background = pygame.image.load("background.png")
surface.blit(self.background, (0, 0))
self.player.render(surface)
self.car.render(surface)
self.car2.render(surface)
self.car3.render(surface)
self.car4.render(surface)
if self.gameover:
self.bye = pygame.image.load("gameover.jpg")
surface.blit(self.bye, (150, 150))
if self.player.getY() >= 550:
self.win = pygame.image.load("youwin.png")
surface.blit(self.win, (150, 150))