示例#1
0
文件: main.py 项目: Babulu/Kirby
def run(event,key,mouse_pos,mouseEvent):
    if data.restart:
        init()
        subscreen.init()
        hand.fistState = False
    if data.start: # Start the game
        if data.play2 == False:
            data.gameMusic.play(-1)
            data.play2 = True
        data.menuMusic.stop()
        if data.pause == False and kirby.life > 0:
            screen.fill((255,255,255))
            landscape.create(screen,spriteGroup) # load the background
            addObject()
            kirby.update(event,screen,key,spriteGroup) # Kirby's movement
            # mouse cursor
            hand.cursor(mouse_pos,mouseEvent,screen,kirby,spriteGroup,key)
        subscreen.run(screen,event,key,kirby,menu) # load subscreen
        clock.tick(20)
    else: # if the game is not started, show the menu
        data.gameMusic.stop()
        if data.play1 == False:
            data.menuMusic.play(-1)
            data.play1 = True
        menu.run(screen,event,key) # run menu
    pygame.display.update()
示例#2
0
def main():
    boot.run(bg, vw, vh, vc, display.FPS)
    Level = menu.run(bg, bg_alpha)

    Action = True
    while True:  ### main game loop
        game = action(Level, Action)
        features.updateCraftsUnit(game.craft.units)  ### Update units

        Level = menu.run(bg, bg_alpha, Levels=True)
        Action = True

        ### Event loop block
        for event in pygame.event.get():
            kind = event.type

            if kind == QUIT:
                pygame.quit()
                sys.exit()

            if kind == KEYDOWN:
                key = event.key

        ### Blit updating
        pygame.display.update()
        FPSClock.tick(FPS)
    def onSave(self, button):
        self.ui.info("Saving")
        fields = self.ui.widgets

        config_data["reddit_client_id"] = fields.clientid.edit_text
        config_data["reddit_client_secret"] = fields.secret.edit_text
        config_data["reddit_username"] = fields.user.edit_text
        config_data["reddit_password"] = fields.password.edit_text

        with open(CONFIG_JSON_FILE, "w+") as config_file:
            config_file.write(json.dumps(config_data, indent=4,
                                         sort_keys=True))
            config_file.close()

        menu.run()
示例#4
0
文件: main.py 项目: joristork/Statred
def print_mean_covariance():
    data = load_iris()
    print '\nMean (overall):\n%s' % str(mean(data))
    print '\nCovariance (overall):\n%s' % str(covariance(data))

    print '\nMean (setosa):\n%s' % str(mean(data[:50]))
    print '\nCovariance (setosa):\n%s' % str(covariance(data[:50]))

    print '\nMean (versicolor):\n%s' % str(mean(data[50:100]))
    print '\nCovariance (versicolor):\n%s' % str(covariance(data[50:100]))

    print '\nMean (virginica):\n%s' % str(mean(data[101:150]))
    print '\nCovariance (virginica):\n%s' % str(covariance(data[101:150]))

    raw_input('\nPress Enter')
    menu.run()
示例#5
0
def main():             #initializes display, defines value for ask module, and writes to the high score file
  screen = pygame.display.set_mode((1200,650))
  main.scoring = ask(screen, "Enter Username")
  main.a = ','+main.scoring+'.'+str(primary.playerScore)
  file.write(main.a)
  menutime = menu.run()
  menutime.runm()
示例#6
0
文件: main.py 项目: joristork/Statred
def plot_iris_means_covariance():
    """ iris samples, means  """
    data = load_iris()
    data_m = mean(data)
    setosa = data[:50]
    setosa_m = mean(setosa)
    versicolor = data[50:100]
    versicolor_m = mean(versicolor)
    virginica = data[100:150]
    virginica_m = mean(virginica)

    """ covariance ellipse (unfinished) """
    phi = np.arange(0, 2 * np.pi, 0.01)
    r_1 = np.outer(np.array([1,0,0,0]), np.cos(phi))
    r_2 = np.outer(np.array([0,1,0,0]), np.sin(phi))
    r = np.transpose(r_1 + r_2)
    ones = np.ones((len(phi),), dtype=float)
    C = covariance(data[:,:4])
    print '\ntest: \n', np.cov(data[:,:4]) == covariance(data[:,:4])
    temp1 = map(lambda x : C * x, r)
    for i in xrange(len(temp1)):
        ellipse = np.inner(r[i], temp1[i])
    x = mean(data[:,:4])
    ellipse = x + np.sqrt(ellipse)

    for i in xrange(4):
        for j in xrange(4):
            if i is not j:
                """ draw samples  """
                plt.subplot(4,4,(1 + j+(i*4)) )
                plt.plot(setosa[:,i],setosa[:,j],'ro', ms=3.0)
                plt.plot(versicolor[:,i],versicolor[:,j],'go', ms=3.0)
                plt.plot(virginica[:,i],virginica[:,j],'bo', ms=3.0)

                """ draw means """
                plt.plot(data_m[i], data_m[j],marker='+',c='black', ms=15.0)
                plt.plot(setosa_m[i], setosa_m[j],marker='+',c='r', ms=15.0)
                plt.plot(versicolor_m[i], versicolor_m[j],marker='+',c='g',ms=15.0)
                plt.plot(virginica_m[i], virginica_m[j],marker='+',c='b',ms=15.0)

                """ draw ellipse  """
                #plt.plot(ellipse)

    plt.show()
    menu.run()
示例#7
0
def mainMenu(mousePosition, mouseClick):
    mainmenu1 = pygame.transform.scale2x(
        pygame.image.load(
            os.path.join('UI' + '\\' + 'Pausemenu' + '\\' +
                         'Mainmenu1.png')).convert_alpha())
    mainmenu2 = pygame.transform.scale2x(
        pygame.image.load(
            os.path.join('UI' + '\\' + 'Pausemenu' + '\\' +
                         'Mainmenu2.png')).convert_alpha())
    mainmenuRect = pygame.rect.Rect(116 * 2, 121 * 2, 100 * 2, 36 * 2)
    if mainmenuRect.collidepoint(mousePosition):
        screen.blit(mainmenu2, mainmenuRect)
        pygame.display.update(mainmenuRect)
        if mouseClick[0] == True:
            pygame.mixer.music.load(os.path.join('Music' '\\' 'main.mp3'))
            pygame.mixer.music.play(-1, 0.0)
            running = False
            menu.run()
            print("muneed")
    else:
        screen.blit(mainmenu1, mainmenuRect)
        pygame.display.update(mainmenuRect)
示例#8
0
def main():
    boot.run(bg, vw, vh, vc, display.FPS)
    Level = menu.run(bg, bg_alpha)

    Action = TRUE
    while True:  ### main game loop
        action(Level, Action)
        Level = menu.run(bg, bg_alpha, Levels=TRUE)
        Action = TRUE

        ### Event loop block
        for event in pygame.event.get():
            kind = event.type

            if kind == QUIT:
                pygame.quit()
                sys.exit()

            if kind == KEYDOWN:
                key = event.key

        ### Blit updating
        pygame.display.update()
        FPSClock.tick(FPS)
示例#9
0
文件: main.py 项目: kstiles/JingQuest
def main():

    # Initialize Pygame
    pygame.init()

    # Create the window
    SCREEN_WIDTH = 960
    SCREEN_HEIGHT = 540
    os.environ["SDL_VIDEO_CENTERED"] = "1"
    gameWindow = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))

    # Create Pygame clock to regulate frames
    clock = pygame.time.Clock()

    # Create a list of game states and a variable to track current state
    states = {"quit" : -1,
              "loading" : 0,
              "menu" : 1,
              "level" : 2,
              "results" : 3,
              "editor" : 4
              }
    
    gameState = states["menu"]

    while gameState != states["quit"]:
        if gameState == states["loading"]:
            pass
        elif gameState == states["menu"]:
            gameState = menu.run(states)
        elif gameState == states["level"]:
            gameState = level.run(states)
        elif gameState == states["editor"]:
            gameState = leveleditor.run(states, "./levels/level.lvl")

    

    # Quit Pygame
    pygame.quit()
示例#10
0
def Main():
  graph = run()
  loop(graph)
示例#11
0
文件: main.py 项目: joristork/Statred
def visualise_covariance():
    

    menu.run()
示例#12
0
 def exit_settings():
     menu.run()
示例#13
0
            transcriber.transcribe(file)  # Transcribe the current file
            logger.msg(file + ' transcribed')
            logger.msg('waiting for files to transcribe...')
        sleep(10)  # Wait for 10 seconds


#--------------------------------------------------------------------------
# Run the settings application
#--------------------------------------------------------------------------
if __name__ == '__main__':

    # Get the configuration file
    config_file_name = join(dirname(realpath(__file__)), '..', 'config.ini')
    configuration_manager = Configuration_Manager(config_file_name)

    # Allow the user to edit the config file and decide whether to run
    server_should_run = ServerShouldRun(False)
    menu.run(configuration_manager, server_should_run)

    if server_should_run.ask():
        logger = Logger(
            join(dirname(realpath(__file__)), '..', 'messages.log'),
            join(dirname(realpath(__file__)), '..', 'errors.log'))
        try:
            run(configuration_manager, logger)
        except Exception as e:
            logger.err(str(e))
            logger.err(
                'Please ensure that the credentials in config.ini are correct and that this machine is connected to the internet'
            )
 def onCancel(self, button):
     self.ui.info("Cancel")
     menu.run()
示例#15
0
文件: main.py 项目: joristork/Statred
            if i is not j:
                """ draw samples  """
                plt.subplot(4,4,(1 + j+(i*4)) )
                plt.plot(setosa[:,i],setosa[:,j],'ro', ms=3.0)
                plt.plot(versicolor[:,i],versicolor[:,j],'go', ms=3.0)
                plt.plot(virginica[:,i],virginica[:,j],'bo', ms=3.0)

                """ draw means """
                plt.plot(data_m[i], data_m[j],marker='+',c='black', ms=15.0)
                plt.plot(setosa_m[i], setosa_m[j],marker='+',c='r', ms=15.0)
                plt.plot(versicolor_m[i], versicolor_m[j],marker='+',c='g',ms=15.0)
                plt.plot(virginica_m[i], virginica_m[j],marker='+',c='b',ms=15.0)

                """ draw ellipse  """
                #plt.plot(ellipse)

    plt.show()
    menu.run()


def visualise_covariance():
    

    menu.run()


if __name__ == "__main__":
    print '\n*** Statistisch redeneren: assignment 1 ***\n'
            
    menu.run()
示例#16
0
        def __init__(self):
                pygame.display.set_caption('Instructions')
 
                display_instructions = True

                clock=pygame.time.Clock()

                dimensions=[1200,650]

                done=False

                font = pygame.font.Font(None, 48)

                screen=pygame.display.set_mode(dimensions)

                display_instructions = True
                instruction_page = 1

                black	= (   0,   0,   0)
                white	= ( 255, 255, 255)

                carrotpic = pygame.image.load ('carrot_final.png')
                cabbagepic = pygame.image.load ('cabbage_final.png')
                molepic = pygame.image.load ('mole_final.png')
                bombpic = pygame.image.load ('bombfusefull_final.png')
                clockpic = pygame.image.load('clock_final.png')
                threepic = pygame.image.load('three_final.png')
                craterpic = pygame.image.load('data/mole_animation_1.gif')


                while done==False and display_instructions:
                        for event in pygame.event.get():
                                if event.type == pygame.QUIT:
                                        done=True #
                                if event.type == pygame.MOUSEBUTTONDOWN:
                                        instruction_page += 1
                                        if instruction_page == 9:
                                                display_instructions = False
                                                
                        
                        screen.fill(black)
                 
                        if instruction_page == 1:
                                text=font.render("How to Play Bomb-A-Mole", True, white)
                                screen.blit(text, [20, 200])

                        if instruction_page == 2:
                                text=font.render("You are a farmer and moles are trying to take your carrots and cabbage.", True, white)
                                screen.blit(text, [20, 200])
                                screen.blit(carrotpic,(460, 500))
                                screen.blit(cabbagepic,(610,500))
                                
                        if instruction_page == 3:
                                text=font.render("So you need to destroy them...", True, white)
                                screen.blit(text, [20, 200])
                                screen.blit(molepic,(520,500))

                        if instruction_page == 4:
                                text=font.render("With Bombs!  (Click to place bombs.)", True, white)
                                screen.blit(text, [20, 200])
                                screen.blit(bombpic,(520,500))

                        if instruction_page == 5:
                                text=font.render("You have to destroy as many moles as you can.", True, white)
                                screen.blit(text, [20, 200])
#                                 screen.blit(clockpic,(520,500))

                        if instruction_page == 6:
                                text=font.render("The mole moves around underground, and eats every other turn.", True, white)
                                screen.blit(text, [20, 200])
#                                 screen.blit(threepic,(520,500))

                        if instruction_page == 7:
                                text=font.render("But remember that every vegetable you bomb is a vegetable you lose.", True, white)
                                screen.blit(text, [20, 200])
                                screen.blit(craterpic,(520,500))

                        if instruction_page == 8:
                                text=font.render("Your score is based on how many moles you bomb.", True, white)
                                screen.blit(text, [20, 100])

                                text=font.render("You get a higher score the more veggies you have when you kill it.", True, white)
                                screen.blit(text, [20, 200])

                                text=font.render("The game is done when there are no more vegetables.", True, white)
                                screen.blit(text, [20, 300])


                        clock.tick(5)
                        
                        pygame.display.flip()

                mymenu = menu.run()
                mymenu.runm()
示例#17
0
	def __init__(self):
		pygame.display.set_caption('High Score')

		# set the window size:
		dimensions=[1200,650]

		font = pygame.font.Font('data/FEASFBRG.ttf', 30)

		screen=pygame.display.set_mode(dimensions)

# load the high score storage file:
		file = open("data/HighScore.txt", "r") 

# read the file:
		intext = file.read()

# split the high score storage into a list of name.score items
		firstText = str(intext).split(',')
		
# create a new list
		secondText = []
		
# Split the strings of name.score into tuples of (name,score) and add those tuples to the new list
		for i in firstText:
			j = str(i).split('.')
			secondText.append(j)

# sort our new list by highest score first
		secondText = sorted(secondText, key = lambda i: int(i[1]), reverse = True)

# take only the top ten scores:
                text1 = secondText[:10]
                
# display those scores on screen:
# (since pygame doesn't support multi-line strings, I had to blit each item at the same x, but a different y
                for i in text1:

                        iIndex = text1.index(i)
                        
                        j = str(i)
                
                        k = str(iIndex+1)+'. '+str(j[1:-1])
                
                        l = font.render(str(k), True, [255,255,255])

# this makes them "stack" on the screen as if they were a multi-line string
                        screen.blit(l, [50, ((iIndex+1)*50)-10])


# main loop:
		while 1:
			for event in pygame.event.get():
				if event.type == pygame.QUIT:
					pygame.quit()
					sys.exit()
                                if event.type == pygame.MOUSEBUTTONDOWN:
                                        mymenu = menu.run()
                                        mymenu.runm()

			pygame.display.flip()
			
			file.close()
示例#18
0
#minimum required version python 3.7.0
import rsa, menu

codificacao = rsa.RSA()
submenus = {
    'Gerar chave publica': codificacao.input_public_key,
    'Encriptar': codificacao.input_encrypt,
    'Desencriptar': codificacao.input_decrypt,
}

menu = menu.Menu(submenus)
menu.run()
示例#19
0
def main():
    menu.run()
示例#20
0
	def __init__(self):
	
		global veggieTotal, playerScore, blitX, blitY, highscorefile
	
# 	set the screen size:
	
		self.size = 1200, 650
		game.screen = pygame.display.set_mode((self.size),0,32)
		
		playerScore = 0
		veggieTotal = 36
		
		self.owSound = pygame.mixer.Sound('data/Music/ow.wav')
		
# 		create the grid of cells:
		
		self.cells = [cell(random.randint(1,2),120,120),cell(random.randint(1,2),201,120),cell(random.randint(1,2),282,120),cell(random.randint(1,2),363,120),cell(random.randint(1,2),444,120),cell(random.randint(1,2),525,120),cell(random.randint(1,2),120,201),cell(random.randint(1,2),201,201),cell(random.randint(1,2),282,201),cell(random.randint(1,2),363,201),cell(random.randint(1,2),444,201),cell(random.randint(1,2),525,201),cell(random.randint(1,2),120,282),cell(random.randint(1,2),201,282),cell(random.randint(1,2),282,282),cell(random.randint(1,2),363,282),cell(random.randint(1,2),444,282),cell(random.randint(1,2),525,282),cell(random.randint(1,2),120,363),cell(random.randint(1,2),201,363),cell(random.randint(1,2),282,363),cell(random.randint(1,2),363,363),cell(random.randint(1,2),444,363),cell(random.randint(1,2),525,363),cell(random.randint(1,2),120,444),cell(random.randint(1,2),201,444),cell(random.randint(1,2),282,444),cell(random.randint(1,2),363,444),cell(random.randint(1,2),444,444),cell(random.randint(1,2),525,444),cell(random.randint(1,2),120,525),cell(random.randint(1,2),201,525),cell(random.randint(1,2),282,525),cell(random.randint(1,2),363,525),cell(random.randint(1,2),444,525),cell(random.randint(1,2),525,525)]
		
# 		load in the garden background image
		
		self.garden = pygame.image.load('garden.png')
		
		self.gardenDisp = self.garden.get_rect(center = (323,323))
		
		self.font = pygame.font.Font('data/FEASFBRG.ttf',30)
		
		self.moleLabel = self.font.render('Mole is hiding under:', True, [255,255,255])
		self.screen.blit(self.moleLabel, [760,60])
		
# 		self.scoreLabel = self.font.render('Score: '+str(playerScore), True, [255,255,255])
# 		self.screen.blit(self.scoreLabel, [760,360])
		
# 		initialize the mole object:
		
		self.mole = mole()
		
		self.cellXblit = 10
		self.cellYblit = 10		
		
# 		primary game loop:
		
		while 1:
			pygame.mouse.set_cursor(cursorsize,(12,12),*mousecursor)
			
			for event in pygame.event.get():
				if event.type == MOUSEBUTTONDOWN:
# 					print 'Mouse clicked!'
					self.mouseLoc = pygame.mouse.get_pos()
# 					print self.mouseLoc
					self.mX = self.mouseLoc[0]
					self.mY = self.mouseLoc[1]
# 					print self.mX,self.mY

					if self.clickCount < 2:
						self.clickCount += 1
					else:
						self.clickCount = 0		

					for i in self.cells:
# 						if i.bombTicker 
# 						self.ticker = i.bombTicker
# 						self.ticker += 1
						i.bombTicker += 1
						cell.placeBomb(i,self.mX,self.mY)
						if i.kind == 3:
							cell.boom(i,i.bombTicker)
# 							self.cellXblit = i.x
# 							self.cellYblit = i.y
# 						if i.kind == 4:
# 							boomAnim.play()
# 							boomAnim.blit(self.screen,(i.x,i.y))
							
					
					mole.move(self.mole,self.cells)
						
				if event.type == pygame.QUIT:
					print 'Game over'
					print 'Score:', playerScore
					pygame.quit()
					sys.exit()
				
			for i in self.cells:
				self.screen.blit(i.image,i.disp)
# 				pygame.display.flip()
				
				if self.mole.x == i.x and self.mole.y == i.y:
					self.moleSquare = i.kind
					if i.kind == 3:
						print 'Mole killed!'
						self.owSound.play()
						playerScore += 20+(veggieTotal*5)
						cell.boom(i,5)
						del self.mole
						self.mole = mole()
					if i.kind == 1 or i.kind == 2:
						cell.eaten(i,self.clickCount)
						#if i.kind == 4:
                                                #        moleAnim.play()
                                                #        moleAnim.blit(self.screen, (1045,300))

			self.moleCell = cell(self.moleSquare,880,160)
			
# blit the animations:
			self.animationBlit(blitX,blitY)
			self.animationBlitm(blitmX,blitmY)
			self.animationBlitd(blitdX,blitdY)
			
# set up a background for the score display:
			self.blackImage = pygame.image.load('data/black.png')
			
			self.blackBox = self.blackImage.get_rect(center = (780,360))
			self.screen.blit(self.blackImage, self.blackBox)
			
# set up the score display:
			self.scoreLabel = self.font.render('Score: '+str(playerScore), True, [255,255,255])
			self.screen.blit(self.scoreLabel, [760,360])
			
			self.screen.blit(self.moleCell.image,self.moleCell.disp)
			pygame.display.flip()
			self.screen.blit(self.garden,self.gardenDisp)
			
# game end logic:
			if veggieTotal == 0:
				print 'Game over'
				print 'Score:', playerScore
                                getinput = uinput.main()
                                getinput.run()
				game.textToWrite = raw_input('Please type a username to save your score: ')
				game.a = ','+self.textToWrite+'.'+str(playerScore)

				print self.a

				file.write(self.a)

				goBack = menu.run()
				goBack.runm()
示例#21
0
 def exit_game():
     menu.run()