当前位置: 首页>>代码示例>>Python>>正文


Python World.draw方法代码示例

本文整理汇总了Python中World.draw方法的典型用法代码示例。如果您正苦于以下问题:Python World.draw方法的具体用法?Python World.draw怎么用?Python World.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在World的用法示例。


在下文中一共展示了World.draw方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: draw

# 需要导入模块: import World [as 别名]
# 或者: from World import draw [as 别名]
 def draw(self):
     World.draw()
开发者ID:davidkoh316,项目名称:gyration_games,代码行数:4,代码来源:GameScreen.py

示例2: serialWrite

# 需要导入模块: import World [as 别名]
# 或者: from World import draw [as 别名]
            lastExplosion = last_ticks
            isExploding = 1
            serialWrite(s, 'A')
            serialWrite(s, 'R')
        if isExploding == 1:
            # for x in range(0, dims[0]):
            #     for y in range(0, dims[1]):
            c = pygame.Color(0)
            c.hsva = ((int(last_ticks)) % 360, 90, 90, 100)
            # pygame.draw.rect(screen, c, pygame.Rect(0, 0, width, height))

            sur = pygame.Surface((width, height))
            sur.set_alpha(128)
            sur.fill(c)
            screen.blit(sur, (0,0))
            if last_ticks - lastExplosion > 1000:
                serialWrite(s, 'B')
                isExploding = 2
        if isExploding == 2 and score % 5 != 0:
            isExploding = 0

        world.draw(screen)
        # if current_milli_time() - lastUpdate >= updateInterval:
        world.update()
        # lastUpdate = current_milli_time()
        if snake.dead:
            serialWrite(s, 'K')
            gameStage = 1
    score = (snake.length - 1) // 2;
    pygame.display.flip()
开发者ID:krx,项目名称:HackNRB,代码行数:32,代码来源:Main.py

示例3: __init__

# 需要导入模块: import World [as 别名]
# 或者: from World import draw [as 别名]
class Game:
    def __init__(self, controller, resolution):
        self.controller = controller
        self.current_frame = 0
        self.resolution = resolution
        self.font = pygame.font.SysFont("consolas", resolution[0]/20)

        self.world = World(resolution)
        self.player = Player(self)

        self.score = 0

    def draw(self, screen):
        self.world.draw(screen, self.resolution, self.player)
        self.player.draw(screen, self.resolution)

        # render text
        score_label = self.font.render("Score: " + str(self.score), 0, (0, 0, 0))
        screen.blit(score_label, (2, 0))

        bullets_label = self.font.render("Bullets: " + str(self.player.bullet_count), 0, (0, 0, 0))
        screen.blit(bullets_label, (0, self.resolution[1]/20))

        bullets_label = self.font.render("X: " + str(self.player.x) + " Y: " + str(self.player.y), 0, (0, 0, 0))
        screen.blit(bullets_label, (0, self.resolution[1]/10))

        bullets_label = self.font.render("Angle: " + str(self.player.angle), 0, (0, 0, 0))
        screen.blit(bullets_label, (0, 1.5*self.resolution[1]/10))

    def update(self, framerate):
        self.current_frame += framerate
        self.player.action()
        self.world.update(framerate, self.player)

    def kill(self, animal):
        self.score += animal.weight * animal.age
        self.world.animals.remove(animal)

    def end(self):
        self.controller.change_view('main_menu')
        return

    def key_press(self, key):
        #ARROWS
        if key == 275:
            self.player.add_move_direction('R')
        elif key == 273:
            self.player.add_move_direction('U')
        elif key == 276:
            self.player.add_move_direction('L')
        elif key == 274:
            self.player.add_move_direction('D')
        #Z
        elif key == 122:
            self.player.use('PRIMARY')
        #X
        elif key == 120:
            self.player.use('SECONDARY')
        #ENTER
        elif key == 13:
            return
        #SHIFT
        elif key == 303:
            return

    def key_release(self, key):
        if key == 275:
            self.player.remove_move_direction('R')
        elif key == 273:
            self.player.remove_move_direction('U')
        elif key == 276:
            self.player.remove_move_direction('L')
        elif key == 274:
            self.player.remove_move_direction('D')
开发者ID:Emile-Filteau,项目名称:RedneckDeerHunting,代码行数:76,代码来源:Game.py


注:本文中的World.draw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。