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


Python Menu.draw方法代码示例

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


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

示例1: main

# 需要导入模块: import Menu [as 别名]
# 或者: from Menu import draw [as 别名]
def main():

	width = 1024
	height = 768
	pygame.display.init
	menu_screen = pygame.display.set_mode((width,height))
	
	# Background
	background = pygame.image.load(os.path.join('', 'images', 'menu_bg.jpg'))
	background = background.convert()
	
	# Cursor
	pygame.mouse.set_visible(False)
	cursor = Cursor(16,16,'images/cursor.png')
	
	#Options in menu
	new_game = Option(200,200,173,89,'images/little.png','images/big.png',new_game_function, 1.42)

	# Menu
	menu = Menu()
	menu.append(new_game)
	
	menu_screen.blit(background, (0, 0))
	cursor.draw(menu_screen)
	menu.draw(menu_screen)
	pygame.display.flip()
	
	# Event loop
	while 1:
		menu.update(cursor)
		for event in pygame.event.get():
			if event.type == QUIT:
				pygame.display.quit
				sys.exit()
			if event.type == KEYDOWN and event.key == K_ESCAPE:
				running = False
				return
			elif event.type == MOUSEMOTION:
				pygame.mouse.get_pos()
				cursor.update()
			elif event.type == MOUSEBUTTONDOWN:
				menu.activate()

		menu_screen.blit(background, (0, 0))
		menu.draw(menu_screen)
		cursor.draw(menu_screen)
		pygame.display.flip()
开发者ID:r0qs,项目名称:chubby,代码行数:49,代码来源:Menu_example.py

示例2:

# 需要导入模块: import Menu [as 别名]
# 或者: from Menu import draw [as 别名]
          menu.seleccion=0
          menu_principal = False
          history = True

        if menu.seleccion==2:
          print"nuevo"
          menu.seleccion=0
          menu_principal = False
          history = True

        if menu.seleccion==3:
          print"salir"
          menu.seleccion=0
          fin=True

        menu.draw(pantalla)
        pygame.display.flip()
         

      #----------------------------------------------------------------------------

      if history:
        pantalla.blit(history_1,(0,0))
        pygame.display.flip() 
        time.sleep(10)
        pantalla.blit(history_2,(0,0))
        pygame.display.flip() 
        time.sleep(10)
        pantalla.blit(history_3,(0,0))
        pygame.display.flip() 
        time.sleep(10)
开发者ID:jeacevedo92,项目名称:Computacion_Grafica,代码行数:33,代码来源:Main.py

示例3:

# 需要导入模块: import Menu [as 别名]
# 或者: from Menu import draw [as 别名]
        particle.start(ship)

    if handler.keys['right']:
      ship.move_right()
    if handler.keys['left']:
      ship.move_left()

    ship.redraw()

    if particle.is_visible():
      particle.render()

    logic.draw_enemies()

    if logic.win_level():
      logic.next_level()

  else:
    menu.draw(pygame, screen)
    if handler.keys['space']:
      menu.started = True
  if logic.is_game_over() or logic.win_game():
     if handler.keys['space']:
      menu.started = True
      logic.restart_game()
  time_passed = clock.tick(60)


  pygame.display.flip()
  pygame.time.wait(5)
开发者ID:anst,项目名称:space,代码行数:32,代码来源:Space.py

示例4: __init__

# 需要导入模块: import Menu [as 别名]
# 或者: from Menu import draw [as 别名]
class Game: 
	'''
	'''

	def __init__(self):
		self.loading = LoadingScreen(self)
		self.camera = Camera(self)
		self.lighting = Lighting(self)
		self.balltable = BallTable(self)
		self.menu = Menu(self)
		self.decision = Decision(self)
		self.mousekey = MouseKey(self)
		self.shotStrength = ShotStrength(self)
		self.state = GameState.START
		self.mode = GameMode.TUTORIAL
		self.balls = [ Ball(self) ]*16
		self.ballinHole = [ None ] * 16
		self.LastFrameTimePoint = 0
		
	def Load(self):
		glutInit(sys.argv)
		glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB|GLUT_DEPTH)
		glutInitWindowSize(ParamDef.ScreenResolution[0], ParamDef.ScreenResolution[1])
		glutInitWindowPosition(0,0)
		glutCreateWindow(APP_NAME)
		glClearColor(0,0,0,0)
		glutIdleFunc(self.loading.Idle)
		glutDisplayFunc(self.loading.UpdateGL)
		self.currentWindow = glutGetWindow()
		glutMainLoop()

	def Run(self):
		ParamDef.DelayCompensation=1
		glutIgnoreKeyRepeat(1)
		glEnable(GL_DEPTH_TEST)
		glEnable(GL_CULL_FACE)
		glEnable(GL_NORMALIZE)
		glEnable(GL_BLEND)
		glShadeModel(GL_SMOOTH)
		glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST)
		glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)

		glutMouseFunc(self.mousekey.MouseClick);
		glutMotionFunc(self.mousekey.MouseMove);
		glutKeyboardFunc(self.mousekey.KeyPress);
		glutKeyboardUpFunc(self.mousekey.KeyRelease);
		glutSpecialFunc(self.mousekey.SpecialKeyPress);
		glutSpecialUpFunc(self.mousekey.SpecialKeyRelease)

		glutVisibilityFunc(self.Visible)
		glutIdleFunc(self.timerEvent)
		glutDisplayFunc(self.updateGL)

	def timerEvent(self):
		#print "timerEvent"
		ParamDef.FrameTimePoint=glutGet(GLUT_ELAPSED_TIME)/10
		ParamDef.Factor=ParamDef.FrameTimePoint-self.LastFrameTimePoint;

		if (ParamDef.DelayCompensation !=0 ) :
			ParamDef.Factor=1;
			ParamDef.DelayCompensation=0;

		if (ParamDef.Factor !=0) :
			if (ParamDef.ShowFPS) :
				if ((ParamDef.FrameTimePoint%200)<(self.LastFrameTimePoint%200)) :
					self.menu.SetFPS(Frames/2);
					ParamDef.Frames=0;
				else:
					ParamDef.Frames+=1

			self.menu.Update(ParamDef.Factor);

			if self.state == GameState.START: 
				self.StartHandling()
			elif self.state == GameState.VIEWING: 
				self.ViewingHandling()
			elif self.state == GameState.AIMING: 
				self.AimHandling()
			elif self.state == GameState.SWING: 
				self.BackswingHandling()
			elif self.state == GameState.SHOT: 
				self.ShotHandling()
			elif self.state == GameState.NEW_WHITE: 
				self.NewWhiteHandling()
			elif self.state == GameState.JUDGEING: 
				self.JudgeHandling()

			self.camera.Ride(ParamDef.Factor);
			self.LastFrameTimePoint=ParamDef.FrameTimePoint;
			glutPostWindowRedisplay(self.currentWindow);

	def updateGL(self):
		'''
		'''
		#print "updateGL"
		if ParamDef.ZBufferDelete != 0:
			glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)

		self.camera.draw()
		self.lighting.draw()
#.........这里部分代码省略.........
开发者ID:ZhuZhengyi,项目名称:pyBillardGL,代码行数:103,代码来源:BillardGL.py

示例5:

# 需要导入模块: import Menu [as 别名]
# 或者: from Menu import draw [as 别名]
import Menu

pygame.init()

screen = pygame.display.set_mode([600,440])
pygame.display.set_caption('Snake')

game = Game.game()
game.init()

gamepad = pygame.Surface([400,400])
Game.draw(gamepad,game.snake,game.food)
screen.blit(gamepad,[20,20])

sidebar = pygame.Surface([150,400])
Menu.draw(sidebar, [0,0])
screen.blit(sidebar,[450,20])

pygame.display.flip()

clock = pygame.time.Clock()

level_speed = [500,350,200,100,50,10]
score_prefd = [10,15,20,25,30,35]

level = 0
pre_step = level_speed[0]
time_pass = 0
isover = False
count = 0
score = 0
开发者ID:AmbBAI,项目名称:JunkCode,代码行数:33,代码来源:Snake.py

示例6: Program

# 需要导入模块: import Menu [as 别名]
# 或者: from Menu import draw [as 别名]
class Program():

    # Booleans to distinguish which game mode you're playing
    isClassicMode = False 

    # Class to handle gameplay in classic mode
    classicMode = MainGame(WIDTH, HEIGHT)

    # The game menu
    menu = Menu(WIDTH, HEIGHT)

    # The screen, for to drawz stuff on
    screen = pygame.display.set_mode([WIDTH, HEIGHT])

    # The clock, used to regulate frame rate
    clock = pygame.time.Clock()

    def __init__(self):
        pygame.init()

    def execute(self):
        while 1:
            # The menu was just closed
            # Start the game
            if not self.menu.is_open() and not self.isClassicMode:
                self.isClassicMode = True 
                self.menu.stopMusic()
                self.classicMode.startGame()

            # The game ended, go back to the menu and reset the game
            if self.classicMode.is_over():
                self.isClassicMode = False 
                self.classicMode.endGame()
                self.classicMode = MainGame(WIDTH, HEIGHT)
                self.menu = Menu(WIDTH, HEIGHT)

            for event in pygame.event.get():
                if event.type == QUIT:
                    pygame.quit()
                    sys.exit()

                if self.isClassicMode: 
                    self.classicMode.handleInput(event)
                else:
                    self.menu.handleInput(event)

            if self.isClassicMode and not self.classicMode.is_paused():
                self.classicMode.play()
            else:
                self.menu.update()

            self.screen.fill([0, 0, 0])

            if self.isClassicMode:
                self.classicMode.draw()
            else:
                self.menu.draw()

            pygame.display.flip()

            # regulate the frame rate to 60 fps
            self.clock.tick(60)
开发者ID:nickihilker,项目名称:frogger-1,代码行数:64,代码来源:Program.py


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