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


Python Ball.color方法代码示例

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


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

示例1: main

# 需要导入模块: from ball import Ball [as 别名]
# 或者: from ball.Ball import color [as 别名]
def main():
    """ Main function for the game. """
    pygame.init()

    # Set the width and height of the screen [width,height]
    size = [800, 600]
    screen = pygame.display.set_mode(size)

    pygame.display.set_caption("CMSC 150 is cool")

    # Loop until the user clicks the close button.
    done = False

    # Used to manage how fast the screen updates
    clock = pygame.time.Clock()


    theBall = Ball()
    theBall.x = 100
    theBall.y = 100
    theBall.change_x = 2
    theBall.change_y = 1
    theBall.color = [255,0,0]

    # -------- Main Program Loop -----------
    while not done:
        # ALL EVENT PROCESSING SHOULD GO BELOW THIS COMMENT
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                done = True
        # ALL EVENT PROCESSING SHOULD GO ABOVE THIS COMMENT

        # ALL GAME LOGIC SHOULD GO BELOW THIS COMMENT

        # ALL GAME LOGIC SHOULD GO ABOVE THIS COMMENT

        # ALL CODE TO DRAW SHOULD GO BELOW THIS COMMENT

        # First, clear the screen to white. Don't put other drawing commands
        # above this, or they will be erased with this command.

        # ALL CODE TO DRAW SHOULD GO ABOVE THIS COMMENT

        screen.fill(BLACK)
        theBall.move()
        theBall.draw(screen)

        # Go ahead and update the screen with what we've drawn.
        pygame.display.flip()

        # Limit to 60 frames per second
        clock.tick(60)

    # Close the window and quit.
    # If you forget this line, the program will 'hang'
    # on exit if running from IDLE.
    pygame.quit()
开发者ID:tazz0009,项目名称:pygameTest1,代码行数:59,代码来源:ball_main.py

示例2: range

# 需要导入模块: from ball import Ball [as 别名]
# 或者: from ball.Ball import color [as 别名]
#initiation for pygame
pygame.init()
SCREENWIDTH = 1800
SCREENHEIGHT = 900
SCREEN = pygame.display.set_mode((SCREENWIDTH,SCREENHEIGHT))
CLOCK = pygame.time.Clock()
NUMBALLS = 1

#color assignments
BLACK = pygame.Color(0,0,0)
WHITE = pygame.Color(255,255,255)
RED = pygame.Color(255,0,0)
BLUE = pygame.Color(0,255,0)
GREEN = pygame.Color(0,0,255)


ball_list = []
for i in range(NUMBALLS):
	ball = Ball(SCREENWIDTH,SCREENHEIGHT)
	if i == 0:
		ball.death = True
		ball.color = BLACK
	ball_list.append(ball)

#main function
def main():
	gox(ball_list,SCREEN,WHITE,RED,CLOCK,(SCREENWIDTH,SCREENHEIGHT))

#calling the main function
main()
开发者ID:Xanuthatusu,项目名称:ballProgram,代码行数:32,代码来源:main.py


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