def execute_drop(item_id):
    """This function takes an item_id as an argument and moves this item from the
  player's inventory to list of items in the current room. However, if there is
  no such item in the inventory, this function prints "You cannot drop that."
  """
    b = 0

    # loop over items in inventory
    for item in inventory:

        # if item input matches item id (i.e. item in inventory)
        if item_id == item["id"]:

            # if item is soap-
            if item["id"] == "soap":
                game_over(
                    "You dropped the soap. NEVER DROP THE SOAP IN PRISON.")

            # otherwise remove item from inventory
            inventory.remove(item)

            # add item to current room items list
            current_room["items"].append(item)

            # print message
            print("\nYou dropped " + item["name"] + ".")
            # increment b if item found
            b = 1

    # if b is 0 then item not in inventory
    if b == 0:
        print("\nYou cannot drop that.\n")
Exemplo n.º 2
0
    def dead_cubes_operator(self):
        """Сортирует неподвижные кубики.
        Удаляет кубики из уничтоженных линий.

        """
        for dead_cube in self.dead_cubes:
            if dead_cube.y == 0:
                game_over(self.screen, self.curr_lines, self.curr_points)
            if not (0 < dead_cube.x < 17 and 0 < dead_cube.y < 21):
                self.dead_cubes.remove(dead_cube)
Exemplo n.º 3
0
def execute_drop(item_id):
    """This function takes an item_id as an argument and moves this item from the
    player's inventory to list of items in the current room. However, if there is
    no such item in the inventory, this function prints "You cannot drop that."
    """
    b =0
    for x in inventory:
        if item_id == x["id"]:
            if x["id"] == "soap":
                game_over("You dropped the soap.")
                exit()
            inventory.remove(x)
            b = b +1
            current_room["items"].append(x)


    if b == 0:
        print("you cannot drop that")
def execute_kill(weapon):
    """this function takes a weapon as an input, check if it's in your inventory, looks up 
    damage value from item dictionary, and multiplies it by a random number 1-5, then updates
    guard to False if more than 20. """

    global guard
    global bypass

    # set chance as random integer between 1-5
    chance = randint(1, 5)

    # if weapon used is bare hands, then set damage as 1 and test
    if weapon == "hands":
        if chance + 1 >= 5:
            print("\nYou successfuly killed the guard!\n")
            guard = False
            bypass = True
            # add guard's unfiform to room items
            current_room["items"].append(item_guard_disguise)

        else:
            game_over(
                "The guard was stronger than you and you died. Bad luck.")
            guard = False

    else:
        #loop through items in inventory looking for weapon id that matches user input
        for item in inventory:
            if item["id"] == weapon:

                #guard dies if chance * item damage is greater than 20
                if item["damage"] * chance > 20:
                    guard = False
                    bypass = True
                    print("\nYou successfuly killed the guard!\n")
                    # add guard's unfiform to room items
                    current_room["items"].append(item_guard_disguise)
                else:
                    guard = False
                    game_over(
                        "The guard was stronger than you and you died. Bad luck."
                    )
Exemplo n.º 5
0
def main():

    ygame_world = game_world()
    game_over2 = game_over()

    yoel_engine.camera = {'x': 5, 'y': 0, 'z': -2, 'f': 1}

    yoel_engine.add_world(ygame_world, "game_world")
    yoel_engine.add_world(game_over2, "game_over")

    yoel_engine.change_world("game_world")

    yoel_engine.init(20)
Exemplo n.º 6
0
def game_screen_6():
    global circ
    global r6a
    global r6b
    global r6c
    global r6d
    global r6f
    global r6g
    global r6h
    global r6j
    global r6k
    global r6l
    global r6m
    global r6n
    global r6o
    global r6p
    global r6q
    global r6r
    global r6s
    global r6t
    global r6u
    global r6v
    global r6w
    global r6x
    global r6y
    global r6z
    global b6a
    global b6b
    global b6c
    global b6d
    global b6e
    global b6f
    global b6g
    global b6h
    global b6i
    global b6j
    global b6k
    global b6l
    global g6a
    global g6b
    global g6c
    global g6d
    global g6e
    global g6f
    global g6g
    global g6h
    global g6i
    global g6j
    global g6k
    global g6l
    global y6a
    global y6b
    global y6c
    global y6d
    global y6e
    global y6f
    global y6g
    global y6h
    global y6i
    global y6j
    global y6k
    global y6l
    global y6m
    global y6n
    global y6o
    global y6p
    global flow
    global done6_r
    global done6_b
    global done6_g
    global done6_y
    screen_6 = pygame.display.set_mode((X, Y))
    running = 1  #This is for the condition in the while loop
    while running:
        for event in pygame.event.get():
            if (event.type == pygame.QUIT):
                pygame.quit()
                quit()
            elif (event.type == pygame.KEYDOWN):
                if (event.key == pygame.K_ESCAPE):
                    pygame.quit()
                    quit()
                elif (event.key == pygame.K_b):
                    flow = 0
                    return
                    pygame.display.update()
    #Iteration for horizontal lines
        y = 125  #starting point
        while (y <= 425):
            pygame.draw.line(
                screen_6, (255, 153, 153), (125, y),
                (425, y))  #code for line from one co-ordinate to another
            y += 50  #increasing 40 for each iteration because the width of each is 40
        x = 125  #Variable for vertical lines
        #Iteration for vertical lines
        while (x <= 425):
            pygame.draw.line(screen_6, (255, 153, 153), (x, 125), (x, 425))
            x += 50
    #Drawing coloured circles
        pygame.draw.circle(screen_6, RED, (200, 200), 20)
        pygame.draw.circle(screen_6, GREEN, (350, 200), 20)
        pygame.draw.circle(screen_6, BLUE, (150, 250), 20)
        pygame.draw.circle(screen_6, GREEN, (150, 300), 20)
        pygame.draw.circle(screen_6, YELLOW, (150, 400), 20)
        pygame.draw.circle(screen_6, YELLOW, (300, 200), 20)
        pygame.draw.circle(screen_6, BLUE, (250, 300), 20)
        pygame.draw.circle(screen_6, RED, (300, 300), 20)
        #Vertical Borders
        x = 0
        while (x < bgheight):
            pygame.draw.line(screen_6, borcolor[x], ((40 - x), 0),
                             ((40 - x), Y))
            x += 1
        x = 0
        while (x < bgheight):
            pygame.draw.line(screen_6, borcolor[x], ((X - 40) + x, 0),
                             ((X - 40) + x, Y))
            x += 1
    #Horizontal Borders
        y = 0
        while (y < bgheight):
            pygame.draw.line(screen_6, borcolor[y], (30, (40 - y)),
                             (X - 30, (40 - y)))
            y += 1
        y = 0
        while (y < bgheight):
            pygame.draw.line(screen_6, borcolor[y], (30, (Y - 40) + y),
                             (X - 30, (Y - 40) + y))
            y += 1
        label = font.render("Flows :", 0, (255, 255, 255))
        screen_6.blit(label, (130, 110))
        label1 = font.render("Level - 1", 0, (255, 255, 255))
        screen_6.blit(label1, (200, 110))
        for e in pygame.event.get():
            if e.type == pygame.QUIT:
                pygame.quit()
            if e.type == pygame.MOUSEMOTION and pygame.mouse.get_pressed()[0]:
                mx, my = pygame.mouse.get_pos()
                #deciding colour based on mouse position
                if ((mx in range(180, 220) and my in range(180, 220))
                        or (mx in range(280, 320) and my in range(280, 320))):
                    circ = 1  #RED
                elif ((mx in range(130, 170) and my in range(230, 270))
                      or (mx in range(230, 270) and my in range(280, 320))):
                    circ = 2  #BLUE
                elif ((mx in range(130, 170) and my in range(280, 320))
                      or (mx in range(330, 370) and my in range(180, 220))):
                    circ = 3  #GREEN
                elif ((mx in range(130, 170) and my in range(380, 420))
                      or (mx in range(280, 320) and my in range(180, 220))):
                    circ = 4  #YELLOW

                #RED
                if (circ == 1):
                    if (mx in range(r6a, r6b) and my in range(175, 225)):
                        pygame.draw.line(screen_6, RED, (r6b + 25, 200),
                                         (r6a + 16, 200), 20)
                    elif (mx in range(125, 175) and my in range(r6c, r6d)):
                        pygame.draw.line(screen_6, RED, (150, r6d + 25),
                                         (150, r6c + 16), 20)
                    elif (mx in range(r6f, r6g) and my in range(125, 175)):
                        pygame.draw.line(screen_6, RED, (r6f - 25, 150),
                                         (r6g - 25, 150), 20)
                        if (mx not in range(225, 275)):
                            r6f += 50
                            r6g += 50
                        else:
                            continue
                    elif (mx in range(225, 275) and my in range(r6h, r6j)):
                        pygame.draw.line(screen_6, RED, (250, r6h - 34),
                                         (250, r6j - 25), 20)
                        if (my not in range(225, 275)):
                            r6h += 50
                            r6j += 50
                        else:
                            continue
                    elif (mx in range(r6k, r6l) and my in range(225, 275)):
                        pygame.draw.line(screen_6, RED, (r6k - 34, 250),
                                         (r6l - 25, 250), 20)

                    #r6m = 275
                    #r6n = 325
                    elif (mx in range(275, 325) and my in range(r6m, r6n)):
                        pygame.draw.line(screen_6, RED, (300, r6m - 34),
                                         (300, r6n - 25), 20)
                        if (done6_r == 0):
                            done6_r = 1
                            flow += 1
                    if (mx in range(275, 325) and my in range(r6o, r6p)):
                        pygame.draw.line(screen_6, RED, (300, r6p + 25),
                                         (300, r6o + 16), 20)
                    elif (mx in range(r6q, r6r) and my in range(225, 275)):
                        pygame.draw.line(screen_6, RED, (r6r + 25, 250),
                                         (r6q + 25, 250), 20)
                    elif (mx in range(225, 275) and my in range(r6s, r6t)):
                        pygame.draw.line(screen_6, RED, (250, r6t + 34),
                                         (250, r6s + 25), 20)
                        if (my not in range(125, 175)):
                            r6s -= 50
                            r6t -= 50
                        else:
                            continue
                    elif (mx in range(r6u, r6v) and my in range(125, 175)):
                        pygame.draw.line(screen_6, RED, (r6v + 34, 150),
                                         (r6u + 25, 150), 20)
                        if (mx not in range(125, 175)):
                            r6u -= 50
                            r6v -= 50
                        else:
                            continue
                    elif (mx in range(125, 175) and my in range(r6w, r6x)):
                        pygame.draw.line(screen_6, RED, (150, r6w - 25),
                                         (150, r6x - 25), 20)
                    elif (mx in range(r6y, r6z) and my in range(175, 225)):
                        pygame.draw.line(screen_6, RED, (r6y - 34, 200),
                                         (r6z - 25, 200), 20)
                        if (done6_r == 0):
                            done6_r = 1
                            flow += 1
                elif (circ == 2):
                    if (mx in range(b6a, b6b) and my in range(225, 275)):
                        pygame.draw.line(screen_6, BLUE, (b6a - 25, 250),
                                         (b6b - 25, 250), 20)
                    elif (mx in range(175, 225) and my in range(b6c, b6d)):
                        pygame.draw.line(screen_6, BLUE, (200, b6c - 34),
                                         (200, b6d - 25), 20)
                    elif (mx in range(b6e, b6f) and my in range(275, 325)):
                        pygame.draw.line(screen_6, BLUE, (b6e - 34, 300),
                                         (b6f - 25, 300), 20)
                        if (done6_b == 0):
                            done6_b = 1
                            flow += 1
                    if (mx in range(b6g, b6h) and my in range(275, 325)):
                        pygame.draw.line(screen_6, BLUE, (b6h + 25, 300),
                                         (b6g + 16, 300), 20)
                    elif (mx in range(175, 225) and my in range(b6i, b6j)):
                        pygame.draw.line(screen_6, BLUE, (200, b6j + 25),
                                         (200, b6i + 16), 20)
                    elif (mx in range(b6k, b6l) and my in range(225, 275)):
                        pygame.draw.line(screen_6, BLUE, (b6l + 25, 250),
                                         (b6k + 25, 250), 20)
                        if (done6_b == 0):
                            done6_b = 1
                            flow += 1
                elif (circ == 3):
                    if (mx in range(125, 175) and my in range(g6a, g6b)):
                        pygame.draw.line(screen_6, GREEN, (150, g6a - 25),
                                         (150, g6b - 16), 20)
                    elif (mx in range(g6c, g6d) and my in range(325, 375)):
                        pygame.draw.line(screen_6, GREEN, (g6c - 25, 350),
                                         (g6d - 16, 350), 20)
                        if (mx not in range(325, 375)):
                            g6c += 50
                            g6d += 50
                        else:
                            continue
                    elif (mx in range(325, 375) and my in range(g6e, g6f)):
                        pygame.draw.line(screen_6, GREEN, (350, g6f + 25),
                                         (350, g6e + 25), 20)
                        if (my not in range(175, 225)):
                            g6e -= 50
                            g6f -= 50
                        else:
                            if (done6_g == 0):
                                done6_g = 1
                                flow += 1
                            continue
                    if (mx in range(325, 375) and my in range(g6g, g6h)):
                        pygame.draw.line(screen_6, GREEN, (350, g6g - 25),
                                         (350, g6h - 25), 20)
                        if (my not in range(325, 375)):
                            g6g += 50
                            g6h += 50
                        else:
                            continue
                    elif (mx in range(g6i, g6j) and my in range(325, 375)):
                        pygame.draw.line(screen_6, GREEN, (g6j + 34, 350),
                                         (g6i + 25, 350), 20)
                        if (mx not in range(125, 175)):
                            g6i -= 50
                            g6j -= 50
                        else:
                            continue
                    elif (mx in range(125, 175) and my in range(g6k, g6l)):
                        pygame.draw.line(screen_6, GREEN, (150, g6l + 34),
                                         (150, g6k + 25), 20)
                        if (done6_g == 0):
                            done6_g = 1
                            flow += 1
                elif (circ == 4):
                    if (mx in range(y6a, y6b) and my in range(375, 425)):
                        pygame.draw.line(screen_6, YELLOW, (y6a - 25, 400),
                                         (y6b - 25, 400), 20)
                        if (mx not in range(375, 425)):
                            y6a += 50
                            y6b += 50
                        else:
                            continue
                    elif (mx in range(375, 425) and my in range(y6c, y6d)):
                        pygame.draw.line(screen_6, YELLOW, (400, y6d + 34),
                                         (400, y6c + 25), 20)
                        if (my not in range(125, 175)):
                            y6c -= 50
                            y6d -= 50
                        else:
                            continue
                    elif (mx in range(y6e, y6f) and my in range(125, 175)):
                        pygame.draw.line(screen_6, YELLOW, (y6f + 34, 150),
                                         (y6e + 25, 150), 20)
                        if (mx not in range(275, 325)):
                            y6e -= 50
                            y6f -= 50
                        else:
                            continue
                    elif (mx in range(275, 325) and my in range(y6g, y6h)):
                        pygame.draw.line(screen_6, YELLOW, (300, y6g - 34),
                                         (300, y6h - 25), 20)
                        if (done6_y == 0):
                            done6_y = 1
                            flow += 1
                    if (mx in range(275, 325) and my in range(y6i, y6j)):
                        pygame.draw.line(screen_6, YELLOW, (300, y6j + 25),
                                         (300, y6i + 16), 20)
                    elif (mx in range(y6k, y6l) and my in range(125, 175)):
                        pygame.draw.line(screen_6, YELLOW, (y6k - 25, 150),
                                         (y6l - 16, 150), 20)
                        if (mx not in range(375, 425)):
                            y6k += 50
                            y6l += 50
                        else:
                            continue
                    elif (mx in range(375, 425) and my in range(y6m, y6n)):
                        pygame.draw.line(screen_6, YELLOW, (400, y6m - 25),
                                         (400, y6n - 25), 20)
                        if (my not in range(375, 425)):
                            y6m += 50
                            y6n += 50
                        else:
                            continue
                    elif (mx in range(y6o, y6p) and my in range(375, 425)):
                        pygame.draw.line(screen_6, YELLOW, (y6p + 34, 400),
                                         (y6o + 25, 400), 20)
                        if (mx not in range(125, 175)):
                            y6o -= 50
                            y6p -= 50
                        else:
                            if (done6_y == 0):
                                done6_y = 1
                                flow += 1
                            continue
        if (flow == 4):
            game_over()
            pygame.display.update()
        pygame.display.flip()
Exemplo n.º 7
0
def main():
	#Abre o arquivo que contem as imformacoes sobre tela Cheia
	arquivo = open('tipo_tela.fs')
	tipo_tela = arquivo.read().strip()
	arquivo.close()
	
	# Iniciliza os modulos do pygame 
	pygame.init()
	
	#Define a Tela 
	tela = Tela("fase1","fundo_fase1_0.png", tipo_tela)
	tela.background_position= [-10,-30]
	
	#Definicao de Leon	
	leon = Leon()
	leon.troca_imagem_mira()
	leon.atualiza_posicao(0,390)
	seletor_image_leon = 1
	controle_velocidade_troca_imagens = 0
	direita = False
	esquerda = False
	cima = False
	#Definicao dos Inimigos
	inimigo = Inimigo()
	inimigo.atualiza_posicao(750, 490)
	seletor_imagem_inimigo = 0
	inimigo.morreu = False
	inimigos_mortos = 0
	
	#definicao do Tiro dos Personagens
	leon_tiro = Tiro(leon.rect)
	direcao_tiro = 'normal'
	inimigo_tiro = Tiro(inimigo.rect)
	inimigo_tiro.atirar = True
	som_tiro = pygame.mixer.Sound("soms" + sep + "tiro.wav")
	atirar = False
	
	#verifica se o boneco deve se deslocar pra cima ou pra baixo
	desliza_cima = False
	desliza_baixo = False
	#DEFINICAO OBSTACULOS:
	pedra = pygame.image.load("imagens"+sep+"imagens"+sep+"pedra2.png")
	ponte = pygame.image.load("imagens"+sep+"imagens"+sep+"ponte1.png")
	
	pular = False
	contador_pulo = 0
	pontuacao = 0
	bonus = Bonus('bonus', 'maca_verde_10.png')
	bonus_aparece = True
	bonus_pontos = Bonus('bonus', 'maca_verde_10.png')
	bonus_pontos_aparece = True
	
	while True:
		clock = pygame.time.Clock()
		clock.tick(100)
		for event in pygame.event.get():
			if event.type is pygame.QUIT:
				exit()
			
			if event.type is KEYDOWN:
				if event.key == K_o:
					leon.troca_imagem_mira()
					leon_tiro.troca_direcao_tiro()
	
		###########Variaveis que devem ser atualizadas em cada laço#######
		# criacao dos obstaculos		
		obstaculo1 = obstaculo_type2(pedra, tela.background_position)
		obstaculo2 = obstaculo_type1(pedra, tela.background_position)
		
		#Verifia se passou de fase			
		if  tela.background_position[0] < -7100:
			b = passa_fase1()
			break 
			
		if bonus_aparece == True:
			bonus.atualiza_posicao(tela.background_position[0]+1800,tela.background_position[1]+300 )
		if bonus_pontos_aparece == True:
			bonus_pontos.atualiza_posicao(obstaculo2[1][0]+50 , obstaculo2[1][1] )
			
		#Criacao das listas de retangulos dos obstaculos
		ret_player = pygame.Rect(leon.rect[0],leon.rect[1],leon.image.get_size()[0],leon.image.get_size()[1])		
		lista_ret_frente = [ret_pedra1type1,ret_pedra2type1]
		lista_ret_left = [ret_pedra2type2,ret_pedra1type2]
		lista_ret_up = [ret_pedra2]
		lista_ret_down = [ret_pedra1]
		lista_ret_sobre_type1 = [ret_pedra1_sobre,ret_pedra2_sobre]
		
		#verifica se os personagens chegaram ao limite da tela
		leon.colide_tela()
		inimigo.colide_tela()
		
		pontuacao = "Score:%04i         vidas: %02i"%(leon.pontuacao, leon.vida)
		tela.imprime_texto(pontuacao, tamanho = 30)
		
		#Controla a posicao do fogo para que fique sempre proximo a leon
		leon_tiro.fogo_rect = [leon.rect[0]+80,leon.rect[1]+39]
		
		#ATIRA: FAZ COM QUE TANTO LEON COMO O INIMIGO ATIRE
		leon_tiro.atira('RIGHT')
		inimigo_tiro.atira('LEFT')
				
		if inimigo_tiro.atirar == False: 
			inimigo_tiro.atirar	= True
		if leon_tiro.atirar and leon_tiro.rect[0] > 800:
			leon_tiro.rect = [leon.rect[0]+80,leon.rect[1]+43]
			leon_tiro.atirar = False
		if inimigo_tiro.atirar and inimigo_tiro.rect[0] < 0:
			inimigo_tiro.atirar	= False
			
		if inimigo.morreu == True and inimigos_mortos < 10:
			inimigo.morreu = False
			
		#Verifica se as vidas de Leon se encerraram
		leon.gameOver()	
		# .encontra_ ()
		#controladores do pulo
		leon.alterna_posicao()	
		
		if pular == True: leon.collide_obstaculo(True)
		
		elif pular == False: leon.collide_obstaculo(False)
		
		#controla a imagem a ser usada no  movimento dos Personagens
		if seletor_image_leon  > 6:
			seletor_image_leon = 1
		if seletor_imagem_inimigo >5:
			seletor_imagem_inimigo = 0
		

		#define a imagem ,possibilita que se alterne e faz com que o inimigo se movimete
		inimigo.image = inimigo.imagem_da_vez[seletor_imagem_inimigo]
		if inimigo.morreu == False:
			inimigo.anda('LEFT', seletor_imagem_inimigo)
			
		else:
			inimigo.atualiza_posicao(500,400)
			
		#Chamada das teclas
		pressed_keys = pygame.key.get_pressed()
		if cima == True:
			direita = False
			esquerda = False
		#inimigo.atualiza_posicao(inimigo.rect[0] -5, inimigo.rect[1])
		if pressed_keys[K_ESCAPE]:
			break
		if pressed_keys[K_PAUSE]:
			a = pausa()
			if a == 'menu':
				break 
				
		#controla o movimento de Leon
		if (pressed_keys[K_RIGHT] and ret_player.collidelist(lista_ret_frente) == -1) or (pressed_keys[K_RIGHT] and contador_pulo >= 10):
			leon_tiro.fogo_rect = (leon.rect[0]+85,leon.rect[1]+25)
			if leon.rect[0] > 400 and tela.background_position[0] > -7200:
				tela.movimenta_background()
				leon.anda('tImage', seletor_image_leon)
			else:
				leon.anda('RIGHT', seletor_image_leon)
				
		elif (pressed_keys[K_LEFT] and ret_player.collidelist(lista_ret_left) == -1) or (pressed_keys[K_LEFT] and contador_pulo >= 10):
			fogo_position = (leon.rect[0]+85,leon.rect[1]+25)
			if leon.rect[0] < 0 and tela.background_position[0] >0:
				tela.movimenta_background()
				leon.anda('tImage', seletor_image_leon)
			else:
				leon.anda('LEFT', seletor_image_leon)

		
		elif pressed_keys[K_UP] and ret_player.collidelist(lista_ret_up) == -1:
			leon.desliza_cima (seletor_image_leon)
			
		elif pressed_keys[K_DOWN] and ret_player.collidelist(lista_ret_down) == -1 and pular == False:
			leon.desliza_baixo (seletor_image_leon)
			
		else:
			seletor_image_leon = 0 
			leon.anda()
			
		#faz o pulo de Leon
		if pular == True and contador_pulo < 10:
			contador_pulo += 1
			if leon.rect[0] < 586:
				leon.rect[0] += 15
			leon.rect[1] -= 15
		elif pular == True and contador_pulo < 20:
			if ret_player.collidelist(lista_ret_sobre_type1) == -1:
				if leon.rect[0] < 586:
					leon.rect[0] += 15
				leon.rect[1] += 15
				contador_pulo += 1
				
		elif contador_pulo == 20:
			pular = False
			contador_pulo = 0
		if pressed_keys[K_p]:
			leon_tiro.atirar = True
			som_tiro.play()
			
		if pressed_keys[K_i]:
			if pular == False:
				pular = True
				#contador_pulo = 0
				
		if pressed_keys[K_ESCAPE]:
			break
		
		
		if leon_tiro.atirar and pygame.sprite.collide_mask(leon_tiro, inimigo):
			inimigo.morre()
			inimigo.morreu = True
			inimigos_mortos += 1
			leon.pontua()
			
		if (inimigo.morreu == False) and (inimigo.morreu == False) and pygame.sprite.collide_mask(leon, inimigo) and leon.cima_obstaculo == False:
			leon.atualiza_posicao(0,390)
			inimigo.atualiza_posicao(inimigo.posicoesX[inimigo.posicaoX], inimigo.posicoesY[inimigo.posicaoY])
			leon.morre()
			
		if (pular == True) and pygame.sprite.collide_mask(leon_tiro, bonus): 
			leon.vida += 1
			bonus.atualiza_posicao(bonus.rect[0] + 2000, bonus.rect[1])
			bonus_aparece = False
			
		if pygame.sprite.collide_mask(leon, bonus_pontos): 
			leon.pontuacao += 100
			bonus_pontos.atualiza_posicao(obstaculo1[1][0] + 2000, obstaculo1[1][1])
			bonus_pontos_aparece = False
			
		tela.screen.fill((0,0,0))
		#colocacao da imagem de fundo na tela
		tela.screen.blit(tela.background, tela.background_position)
		
		#colocacao dos personagens na tela
		
		if inimigos_mortos > 10:
			inimigo.morreu = True
				
		if inimigo.morreu == False:
			tela.screen.blit(inimigo.image,inimigo.rect)
		
		tela.screen.blit(obstaculo1[0] , obstaculo1[1])
		
		tela.screen.blit(bonus.image, bonus.rect)	
		
		if pular == True:
			tela.screen.blit(obstaculo2[0] , obstaculo2[1])
			tela.screen.blit(bonus_pontos.image, bonus_pontos.rect)	
			tela.screen.blit(leon.image, leon.rect)
			
		elif pular == False:
			tela.screen.blit(leon.image, leon.rect)
			tela.screen.blit(obstaculo2[0] , obstaculo2[1])
			tela.screen.blit(bonus_pontos.image, bonus_pontos.rect)	
			
			
		if leon_tiro.atirar and leon_tiro.rect[0] < 800:
			tela.screen.blit(leon_tiro.image , leon_tiro.rect)
			
		if inimigo_tiro.atirar and inimigo_tiro.rect[0] > 0:
			tela.screen.blit(inimigo_tiro.image , inimigo_tiro.rect)
			
		#Imprime a pontuacao
		tela.screen.blit(tela.frase,tela.frase_position)
		
		
		if leon.game_over:
			game_over()
			break
		#atualiza a tela
		pygame.display.update()
		
		#faz com que as imagens dos personagens variem
		if controle_velocidade_troca_imagens % 5 == 0:
			seletor_image_leon += 1	
			seletor_imagem_inimigo += 1	
		controle_velocidade_troca_imagens += 1
Exemplo n.º 8
0
def game_screen_6_l2():
    global circ
    global r2a
    global r2b
    global r2c
    global r2d
    global r2e
    global r2f
    global r2g
    global r2h
    global g2a
    global g2b
    global g2c
    global g2d
    global g2e
    global g2f
    global g2g
    global g2h
    global g2i
    global g2j
    global g2k
    global g2l
    global b2a
    global b2b
    global b2c
    global b2d
    global y2a
    global y2b
    global y2c
    global y2d
    global o2a
    global o2b
    global o2c
    global o2d
    global o2e
    global o2f
    global o2g
    global o2h
    global o2i
    global o2j
    global o2k
    global o2l
    global o2m
    global o2n
    global o2o
    global o2p
    global o2q
    global o2r
    global o2s
    global o2t
    global flow
    global done2_r
    global done2_g
    global done2_b
    global done2_y
    global done2_o



    screen_6_l2 = pygame.display.set_mode((X,Y))
    running = 1                                 #This is for the condition in the while loop
    while running:
        for event in pygame.event.get():
            if(event.type == pygame.QUIT):
                pygame.quit()
                quit()
            elif(event.type == pygame.KEYDOWN):
                if(event.key == pygame.K_ESCAPE):
                    pygame.quit()
                    quit()
                elif(event.key == pygame.K_b):
                    flow = 0
                    return
                    pygame.display.update()
   #Iteration for horizontal lines
        y = 125                                                 #starting point
        while(y <= 425):
            pygame.draw.line(screen_6_l2 , (255 , 153 , 153) , (125 , y) , (425,y))   #code for line from one co-ordinate to another
            y += 50                             #increasing 40 for each iteration because the width of each is 40
        x = 125                                   #Variable for vertical lines

    #Iteration for vertical lines
        while(x <= 425):
            pygame.draw.line(screen_6_l2 , (255,153,153) , (x,125) , (x , 425))
            x += 50
    #Drawing coloured circles
        pygame.draw.circle(screen_6_l2, RED, (250,200), 20)
        pygame.draw.circle(screen_6_l2, GREEN, (400, 150), 20)
        pygame.draw.circle(screen_6_l2, BLUE, (350, 150), 20)
        pygame.draw.circle(screen_6_l2, GREEN, (300, 300), 20)
        pygame.draw.circle(screen_6_l2, YELLOW, (250, 300), 20)
        pygame.draw.circle(screen_6_l2, YELLOW, (250, 400), 20)
        pygame.draw.circle(screen_6_l2, BLUE, (350, 350), 20)
        pygame.draw.circle(screen_6_l2, RED, (200, 350), 20)
        pygame.draw.circle(screen_6_l2, ORANGE, (200, 400), 20)
        pygame.draw.circle(screen_6_l2, ORANGE, (250, 250), 20)
    #Vertical Borders
        x = 0
        while(x < bgheight):
            pygame.draw.line(screen_6_l2 , borcolor[x] , ((40 - x),0) , ((40 - x) , Y))
            x += 1
        x = 0
        while(x <  bgheight):
            pygame.draw.line(screen_6_l2 , borcolor[x] , ((X - 40) + x , 0) , ((X - 40) + x , Y))
            x += 1
    #Horizontal Borders
        y = 0
        while(y < bgheight):
            pygame.draw.line(screen_6_l2 , borcolor[y] , (30, (40 - y)) , (X - 30 ,(40 - y)))
            y += 1
        y = 0
        while(y < bgheight):
            pygame.draw.line(screen_6_l2 , borcolor[y] , (30 , (Y-40) + y) , (X - 30,(Y - 40) + y))
            y += 1

        label = font.render("Flows :" , 0 , (255,255,255))
        screen_6_l2.blit(label,(130,110))
        label1 = font.render("Level - 2" , 0 ,(255,255,255))
        screen_6_l2.blit(label1,(240,110))

        for e in pygame.event.get():
            if e.type == pygame.QUIT:
                    pygame.quit()
            if e.type == pygame.MOUSEMOTION and pygame.mouse.get_pressed()[0]:
                mx , my = pygame.mouse.get_pos()
                #deciding colour based on mouse position
                if ((mx in range(225,275) and my in range(175,225)) or (mx in range(175,225) and my in range(325,375))):
                    circ = 1 #RED
                elif ((mx in range(375,425) and my in range(125,175)) or (mx in range(275,325) and my in range(275,325))):
                    circ = 2 #GREEN
                elif ((mx in range(325,375) and my in range(125,175)) or (mx in range(325, 375) and my in range(325, 375))):
                    circ = 3 #BLUE
                elif ((mx in range(225,275) and my in range(275,325)) or (mx in range(225,275) and my in range(375,425))):
                    circ = 4 #YELLOW
                elif ((mx in range(175,225) and my in range(375,425)) or (mx in range(225,275) and my in range(225,275))):
                    circ = 5 #ORANGE
                
                if (circ == 1):
                    if (mx in range(r2a,r2b) and my in range(175,225)):
                        pygame.draw.line(screen_6_l2, RED, (r2b + 25, 200), (r2a + 16, 200), 20)
                    elif (mx in range(175,225) and my in range(r2c,r2d)):
                        pygame.draw.line(screen_6_l2, RED, (200, r2c - 34), (200, r2d-25), 20)
                        if (my not in range(325, 375)):
                            r2c += 50
                            r2d += 50
                        else:
                            if (done2_r == 0):
                                done2_r = 1
                                flow += 1
                            continue
                    if (mx in range(175,225) and my in range(r2e,r2f)):
                        pygame.draw.line(screen_6_l2, RED, (200, r2f + 25), (200, r2e + 25), 20)
                        if (my not in range(175,225)):
                            r2e -= 50
                            r2f -= 50
                        else:
                            continue
                    elif (mx in range(r2g,r2h) and my in range(175,225)):
                        pygame.draw.line(screen_6_l2, RED, (200, r2g - 34), (200, r2h - 25), 20)
                        if (done2_r == 0):
                            done2_r = 1
                            flow += 1
                elif (circ == 2):
                    if (mx in range(375,425) and my in range(g2a, g2b)):
                        pygame.draw.line(screen_6_l2, GREEN, (400, g2a - 25), (400, g2b - 25), 20)
                        if (my not in range(375,425)):
                            g2a += 50
                            g2b += 50
                        else:
                            continue
                    elif (mx in range(g2c,g2d) and my in range(375,425)):
                        pygame.draw.line(screen_6_l2, GREEN, (g2d + 34, 400), (g2c + 25, 400), 20)
                        if (mx not in range(275,325)):
                            g2c -= 50
                            g2d -= 50
                        else:
                            continue
                    elif (mx in range(275,325) and my in range(g2e,g2f)):
                        pygame.draw.line(screen_6_l2, GREEN, (300, g2f + 34), (300, g2e + 25), 20)
                        if (my not in range(275,325)):
                            g2e -= 50
                            g2f -= 50
                        else:
                            if (done2_g == 0):
                                done2_g = 1
                                flow += 1
                            continue
                    if(mx in range(275,325) and my in range(g2g,g2h)):
                        pygame.draw.line(screen_6_l2, GREEN, (300, g2g -25), (300, g2h -25), 20)
                        if (my not in range(375,425)):
                            g2g += 50
                            g2h += 50
                        else:
                            continue
                    elif (mx in range(g2i,g2j) and my in range(375,425)):
                        pygame.draw.line(screen_6_l2, GREEN, (g2i - 34, 400), (g2j - 25, 400), 20)
                        if (mx not in range(375,425)):
                            g2i += 50
                            g2j += 50
                        else:
                            continue
                    elif (mx in range(375,425) and my in range(g2k, g2l)):
                        pygame.draw.line(screen_6_l2, GREEN, (400, g2l + 34), (400, g2k + 25), 20)
                        if (my not in range(125,175)):
                            g2k -= 50
                            g2l -= 50
                        else:
                            if (done2_g == 0):
                                done2_g = 1
                                flow += 1
                            continue
                elif (circ == 3):
                    if (mx in range(325,375) and my in range(b2a,b2b)):
                        pygame.draw.line(screen_6_l2, BLUE, (350, b2a - 25), (350, b2b - 25), 20)
                        if (my not in range(325,375)):
                            b2a += 50
                            b2b += 50
                        else:
                            if (done2_b == 0):
                                done2_b = 1
                                flow += 1
                            continue
                    if (mx in range(325,375) and my in range(b2c,b2d)):
                        pygame.draw.line(screen_6_l2, BLUE, (350, b2d + 25), (350, b2c + 25), 20)
                        if (my not in range(125,175)):
                            b2c -= 50
                            b2d -= 50
                        else:
                            if (done2_b == 0):
                                done2_b = 1
                                flow += 1
                            continue
                elif (circ == 4):
                    if (mx in range(225,275) and my in range(y2a,y2b)):
                        pygame.draw.line(screen_6_l2, YELLOW, (250, y2a - 25), (250, y2b - 25), 20)
                        if (my not in range(375,425)):
                            y2a += 50
                            y2b += 50
                        else:
                            if (done2_y == 0):
                                done2_y = 1
                                flow += 1
                            continue
                    if (mx in range(225,275) and my in range(y2c,y2d)):
                        pygame.draw.line(screen_6_l2, YELLOW, (250, y2d + 25), (250, y2c + 25), 20)
                        if (my not in range(275,325)):
                            y2a += 50
                            y2b += 50
                        else:
                            if (done2_y == 0):
                                done2_y = 1
                                flow += 1
                            continue
                elif (circ == 5):
                    if (mx in range(o2a,o2b) and my in range(375,425)):
                        pygame.draw.line(screen_6_l2, ORANGE, (o2b + 25, 400), (o2a + 16, 400), 20)
                    elif (mx in range(125,175) and my in range(o2c,o2d)):
                        pygame.draw.line(screen_6_l2, ORANGE, (150, o2d + 34), (150, o2c + 25), 20)
                        if (my not in range(125,175)):
                            o2c -= 50
                            o2d -= 50
                        else:
                            continue
                    elif (mx in range(o2e,o2f) and my in range(125,175)):
                        pygame.draw.line(screen_6_l2, ORANGE, (o2e - 34, 150), (o2f -25, 150), 20)
                        if (mx not in range(275,325)):
                            o2e += 50
                            o2f += 50
                        else:
                            continue
                    elif (mx in range(275,325) and my in range(o2g,o2h)):
                        pygame.draw.line(screen_6_l2, ORANGE, (300, o2g - 34), (300, o2h - 25), 20)
                        if (my not in range(225,275)):
                            o2g += 50
                            o2h += 50
                        else:
                            continue
                    elif (mx in range(o2i,o2j) and my in range(225,275)):
                        pygame.draw.line(screen_6_l2, ORANGE, (o2j + 34, 250), (o2i + 25, 250), 20)
                        if (done2_o == 0):
                            done2_o = 1
                            flow += 1
                    if (mx in range(o2k,o2l) and my in range(225,275)):
                        pygame.draw.line(screen_6_l2, ORANGE, (o2k -25, 250), (o2l - 16, 250), 20)
                    elif (mx in range(275,325) and my in range(o2m,o2n)):
                        pygame.draw.line(screen_6_l2, ORANGE, (300, o2n + 34), (300, o2m + 25), 20)
                        if (my not in range(125,175)):
                            o2m -= 50
                            o2n -= 50
                        else:
                            continue
                    elif (mx in range(o2o,o2p) and my in range(125,175)):
                        pygame.draw.line(screen_6_l2, ORANGE, (o2p + 34, 150), (o2o + 25, 150), 20)
                        if (mx not in range(125, 175)):
                            o2o -= 50
                            o2p -= 50
                        else:
                            continue
                    elif (mx in range(125,175) and my in range(o2q, o2r)):
                        pygame.draw.line(screen_6_l2, ORANGE, (150, o2q - 34), (150, o2r - 25), 20)
                        if(my not in range(375,425)):
                            o2q += 50
                            o2r += 50
                        else:
                            continue
                    elif (mx in range(o2s,o2t) and my in range(375,425)):
                        pygame.draw.line(screen_6_l2, ORANGE, (o2s - 34, 400), (o2t - 25, 400), 20)
                        if (done2_o == 0):
                            done2_o = 1
                            flow += 1
        if(flow == 4):
            game_over()
            pygame.display.update()
        pygame.display.flip()
Exemplo n.º 9
0
def game_screen_l2():
    global circ
    global r5a
    global r5b
    global r5c
    global r5d
    global r5e
    global r5f
    global r5g
    global r5h
    global r5i
    global r5j
    global r5k
    global r5l
    global g5a
    global g5b
    global g5c
    global g5d
    global g5e
    global g5f
    global g5g
    global g5h
    global g5i
    global g5j
    global g5k
    global g5l
    global b5a
    global b5b
    global b5c
    global b5d
    global b5e
    global b5f
    global b5g
    global b5h
    global b5i
    global b5j
    global b5k
    global b5l
    global y5a
    global y5b
    global y5c
    global y5d
    global y5e
    global y5f
    global y5g
    global y5h
    global flow
    global done5_r
    global done5_g
    global done5_b
    global done5_y
    screen = pygame.display.set_mode((X,Y))
    running = 1                                 #This is for the condition in the while loop
    while running:
        for event in pygame.event.get():
            if(event.type == pygame.QUIT):
                pygame.quit()
                quit()
            elif(event.type == pygame.KEYDOWN):
                if(event.key == pygame.K_ESCAPE):
                    pygame.quit()
                    quit()
                elif(event.type == pygame.K_b):
                    flow = 0
                    return
                    pygame.display.update()
   #Iteration for horizontal lines
        y = 125                                                 #starting point
        while(y <= 375):
            pygame.draw.line(screen , (255 , 153 , 153) , (125 , y) , (375,y))   #code for line from one co-ordinate to another
            y += 50                             #increasing 40 for each iteration because the width of each is 40
        x = 125                                 #Variable for vertical lines
    #Iteration for vertical lines
        while(x <= 375):
            pygame.draw.line(screen , (255,153,153) , (x,125) , (x , 375))
            x += 50
    #Drawing coloured circles
        pygame.draw.circle(screen, RED, (300, 150), 20)
        pygame.draw.circle(screen, GREEN, (300, 200), 20)
        pygame.draw.circle(screen, BLUE, (250, 200), 20)
        pygame.draw.circle(screen, GREEN, (200, 350), 20)
        pygame.draw.circle(screen, YELLOW, (250, 250), 20)
        pygame.draw.circle(screen, YELLOW, (200, 200), 20)
        pygame.draw.circle(screen, BLUE, (150, 350), 20)
        pygame.draw.circle(screen, RED, (250, 350), 20)
    #Vertical Borders
        x = 0
        while(x < bgheight):
            pygame.draw.line(screen , borcolor[x] , ((40 - x),0) , ((40 - x) , Y))
            x += 1
        x = 0
        while(x <  bgheight):
            pygame.draw.line(screen , borcolor[x] , ((X - 40) + x , 0) , ((X - 40) + x , Y))
            x += 1

    #Horizontal Borders
        y = 0
        while(y < bgheight):
            pygame.draw.line(screen , borcolor[y] , (30, (40 - y)) , (X - 30 ,(40 - y)))
            y += 1
        y = 0
        while(y < bgheight):
            pygame.draw.line(screen , borcolor[y] , (30 , (Y-40) + y) , (X - 30,(Y - 40) + y))
            y += 1

        label = font.render("Flows :" , 0 , (255,255,255))
        screen.blit(label,(120,110))
        label1 = font.render("Level - 2" , 0 ,(255,255,255))
        screen.blit(label1,(300,110))
        for e in pygame.event.get():
            if e.type == pygame.QUIT:
                    pygame.quit()
            if e.type == pygame.MOUSEMOTION and pygame.mouse.get_pressed()[0]:
                mx , my = pygame.mouse.get_pos()
                if ((mx in range(280,320) and my in range(130,170)) or (mx in range(230,270) and my in range(330,370))):
                    circ = 1 #RED
                elif ((mx in range(280,320) and my in range(180,220)) or (mx in range(180,220) and my in range(330,370))):
                    circ = 2 #GREEN
                elif ((mx in range(230,270) and my in range(180,220)) or (mx in range(130,170) and my in range(330,370))):
                    circ = 3 #BLUE
                elif ((mx in range(180,220) and my in range(180,220)) or (mx in range(230,270) and my in range(230,270))):
                    circ = 4 #YELLOW
                if (circ == 1):
                    if (mx in range(r5a,r5b) and my in range(125,175)):
                        pygame.draw.line(screen, RED, (r5a - 25, 150), (r5b - 16, 150), 20)
                    elif (mx in range(325,375) and my in range(r5c,r5d)):
                        pygame.draw.line(screen, RED, (350, r5c - 25), (350, r5d - 25), 20)
                        if (my not in range(325,375)):
                            r5c += 50
                            r5d += 50
                        else:
                            continue
                    elif (mx in range(r5e,r5f) and my in range(325,375)):
                        pygame.draw.line(screen, RED, (r5f + 34, 350), (r5e + 25, 350), 20)
                        if(mx not in range(225,275)):
                            r5e -= 50
                            r5f -= 50
                        else:
                            if (done5_r == 0):
                                done5_r = 1
                                flow += 1
                            continue
                    if (mx in range(r5g,r5h) and my in range(325,375)):
                        pygame.draw.line(screen, RED, (r5g - 25, 350), (r5h - 16, 350), 20)
                        if(mx not in range(325,375)):
                            r5g += 50
                            r5h += 50
                        else:
                            continue
                    elif (mx in range(325,375) and my in range(r5i,r5j)):
                        pygame.draw.line(screen, RED, (350, r5j + 34), (350, r5i + 25), 20)
                        if (my not in range(125,175)):
                            r5i -= 50
                            r5j -= 50
                        else:
                            continue
                    elif (mx in range(r5k,r5l) and my in range(125,175)):
                        pygame.draw.line(screen, RED, (r5l + 34, 150), (r5k + 25, 150), 20)
                        if (done5_r == 0):
                            done5_r = 1
                            flow += 1
                elif (circ == 2):
                    if (mx in range(275,325) and my in range(g5a,g5b)):
                        pygame.draw.line(screen, GREEN, (300, g5a - 25), (300, g5b - 25), 20)
                        if (my not in range(275,325)):
                            g5a += 50
                            g5b += 50
                        else:
                            continue
                    elif (mx in range(g5c,g5d) and my in range(275,325)):
                        pygame.draw.line(screen, GREEN, (g5d + 34, 300), (g5c + 25, 300), 20)
                        if(mx not in range(175,225)):
                            g5c -= 50
                            g5d -= 50
                        else:
                            continue
                    elif (mx in range(175,225) and my in range(g5e,g5f)):
                        pygame.draw.line(screen, GREEN, (200, g5e - 34), (200, g5f - 25), 20)
                        if (my not in range(325,375)):
                            g5e += 50
                            g5f += 50
                        else:
                            if (done5_g == 0):
                                done5_g = 1
                                flow += 1
                            continue
                    if (mx in range(175,225) and my in range(g5g,g5h)):
                        pygame.draw.line(screen, GREEN, (200, g5h + 25), (200, g5g + 16), 20)
                        if (my not in range(275, 325)):
                            g5g -= 50
                            g5h -= 50
                        else:
                            continue
                    elif (mx in range(g5i,g5j) and my in range(275,325)):
                        pygame.draw.line(screen, GREEN, (g5i - 34, 300), (g5j - 25, 300), 20)
                        if(mx not in range(275,325)):
                            g5i += 50
                            g5j += 50
                        else:
                            continue
                    elif (mx in range(275,325) and my in range(g5k,g5l)):
                        pygame.draw.line(screen, GREEN, (300, g5l + 34), (300, g5k + 25), 20)
                        if (my not in range(175,225)):
                            g5k -= 50
                            g5l -= 50
                        else:
                            if (done5_g == 0):
                                done5_g = 1
                                flow += 1
                            continue
                elif (circ == 3):
                    if (mx in range(125,175) and my in range(b5a,b5b)):
                        pygame.draw.line(screen, BLUE, (150, b5b + 25), (150, b5a + 25), 20)
                        if (my not in range(125,175)):
                            b5a -= 50
                            b5b -= 50
                        else:
                            continue
                    elif (mx in range(b5c,b5d) and my in range(125,175)):
                        pygame.draw.line(screen, BLUE, (b5c - 34, 150), (b5d - 25, 150), 20)
                        if (mx not in range(225,275)):
                            b5c += 50
                            b5d += 50
                        else:
                            if (done5_b == 0):
                                done5_b = 1
                                flow += 1
                            continue
                    elif (mx in range(225,275) and my in range(b5e,b5f)):
                        pygame.draw.line(screen, BLUE, (250, b5e - 34), (250, b5f - 25), 20)
                    if (mx in range(225,275) and my in range(b5g,b5h)):
                        pygame.draw.line(screen, BLUE, (250, b5h + 25), (250, b5g + 16), 20)
                    elif (mx in range(b5i,b5j) and my in range(125,175)):
                        pygame.draw.line(screen, BLUE, (b5j + 34, 150), (b5i + 25, 150), 20)
                        if (mx not in range(125,175)):
                            b5i -= 50
                            b5j -= 50
                        else:
                            continue
                    elif (mx in range(125,175) and my in range(b5k,b5l)):
                        pygame.draw.line(screen, BLUE, (150, b5k - 34), (150, b5l - 25), 20)
                        if (my not in range(325,375)):
                            b5k += 50
                            b5l += 50
                        else:
                            if (done5_b == 0):
                                done5_b = 1
                                flow += 1
                            continue
                elif (circ == 4):
                    if (mx in range(175,225) and my in range(y5a,y5b)):
                        pygame.draw.line(screen, YELLOW, (200, y5a - 25), (200, y5b - 25), 20)
                    elif (mx in range(y5c,y5d) and my in range(225,275)):
                        pygame.draw.line(screen, YELLOW, (y5c - 34, 250), (y5d - 25, 250), 20)
                        if (done5_y == 0):
                            done5_y = 1
                            flow += 1
                    if (mx in range(y5e,y5f) and my in range(225,275)):
                        pygame.draw.line(screen, YELLOW, (y5f + 16, 250), (y5e + 25, 250), 20)
                    elif (mx in range(175,225) and my in range(y5g,y5h)):
                        pygame.draw.line(screen, YELLOW, (200, y5h + 34), (200, y5g + 25), 20)
                        if (done5_y == 0):
                            done5_y = 1
                            flow += 1
        if(flow == 4):
            game_over()
            pygame.display.update()
        pygame.display.flip()
Exemplo n.º 10
0
def main():
    input("게임을 시작하려면 엔터")

    print("\n" * 38)

    try:
        import save
    except:

        player_name = input("\n플레이어 이름을 입력하십시오. = ")
        while player_name == "":
            print("\n유효한 이름을 입력하십시오")
            player_name = input("플레이어 이름을 입력하십시오. = ")

        player_1 = Player(player_name, 1, 0, [], [], [], 0, 0, 0)
        plag = 0

    time.sleep(1.3)
    print('\n' * 2)
    print("정상적으로 로그인 되었습니다.")
    time.sleep(0.7)
    print("정보 불러오는 중...")
    time.sleep(0.7)
    print(f"환영합니다. {player_name}님")
    time.sleep(1)

    while True:

        print("\n" * 38)

        turn_chack(player_1)  # 아레나, 스텟(레벨)

        player_1.showinfo()

        print(f"나의스텟 (힘,민첩,모험) : {po_count}/{ag_count}/{ad_count}")

        if plag == 0:
            print("\n도움을 원한다면 'z' 입력")

        ans = input("\n무엇을 하시겠습니까? : ")

        if ans == "q" or ans == "w" or ans == "e" or ans == "r" or ans == "t" or ans == "y":
            match(player_1)
        elif ans == "a":
            martial_arts_inventory(player_1)
        elif ans == "s":
            inventory(player_1, 'item')
            continue
        elif ans == "d":
            showshop(player_1)
            continue
        elif ans == "z":
            print(
                "\n게임설명\n전투시작 : q,w,e,r,t,y\n무술 장착 및 해제 : a\n인벤토리 : s\n상점 : d\n도움말 : z\n게임종료 : p\
                    \n한국어를 웬만하면 누르지 마세요.(버그의 원인이 됩니다.)\n다 읽으셨다면 enter.")
            input()
        elif ans == "p":
            game_over()
        else:
            print("다시 입력해 주십시오")

        plag += 1
Exemplo n.º 11
0
def game_screen_5():
    global ra
    global rb
    global circ
    global rc
    global rd
    global rg
    global rf
    global ga
    global gb
    global gc
    global gd
    global gf
    global gg
    global gh
    global gi
    global ba
    global bb
    global bc
    global bd
    global ya
    global yb
    global yc
    global yd
    global yf
    global yg
    global yh
    global yi
    global oa
    global ob
    global oc
    global od
    global of
    global og
    global oh
    global oi
    global flow
    global done_r
    global done_y
    global done_g
    global done_o
    global done_b
    game_screen_5 = pygame.display.set_mode((X, Y))
    running = 1  #This is for the condition in the while loop
    while running:
        for event in pygame.event.get():
            if (event.type == pygame.QUIT):
                pygame.quit()
                quit()
            elif (event.type == pygame.KEYDOWN):
                if (event.key == pygame.K_ESCAPE):
                    pygame.quit()
                    quit()
                elif (event.key == pygame.K_b):
                    flow = 0
                    return
                    pygame.display.flip()
#Iteration for horizontal lines
        y = 125  #starting point
        while (y <= 375):
            pygame.draw.line(
                game_screen_5, (255, 153, 153), (125, y),
                (375, y))  #code for line from one co-ordinate to another
            y += 50  #increasing 40 for each iteration because the width of each is 40

        x = 125  #Variable for vertical lines

        #Iteration for vertical lines
        while (x <= 375):
            pygame.draw.line(game_screen_5, (255, 153, 153), (x, 125),
                             (x, 375))
            x += 50

    #Drawing coloured circles
        pygame.draw.circle(game_screen_5, RED, (150, 150), 20)
        pygame.draw.circle(game_screen_5, GREEN, (250, 150), 20)
        pygame.draw.circle(game_screen_5, BLUE, (250, 200), 20)
        pygame.draw.circle(game_screen_5, GREEN, (200, 300), 20)
        pygame.draw.circle(game_screen_5, YELLOW, (300, 300), 20)
        pygame.draw.circle(game_screen_5, YELLOW, (350, 150), 20)
        pygame.draw.circle(game_screen_5, BLUE, (250, 350), 20)
        pygame.draw.circle(game_screen_5, RED, (200, 350), 20)
        pygame.draw.circle(game_screen_5, ORANGE, (350, 200), 20)
        pygame.draw.circle(game_screen_5, ORANGE, (300, 350), 20)

        #Vertical Borders
        x = 0
        while (x < bgheight):
            pygame.draw.line(game_screen_5, borcolor[x], ((40 - x), 0),
                             ((40 - x), Y))
            x += 1
        x = 0
        while (x < bgheight):
            pygame.draw.line(game_screen_5, borcolor[x], ((X - 40) + x, 0),
                             ((X - 40) + x, Y))
            x += 1

    #Horizontal Borders
        y = 0
        while (y < bgheight):
            pygame.draw.line(game_screen_5, borcolor[y], (30, (40 - y)),
                             (X - 30, (40 - y)))
            y += 1
        y = 0
        while (y < bgheight):
            pygame.draw.line(game_screen_5, borcolor[y], (30, (Y - 40) + y),
                             (X - 30, (Y - 40) + y))
            y += 1

        label = font.render("Flows :" + str(flow), 0, (255, 255, 255))
        game_screen_5.blit(label, (120, 110))
        label1 = font.render("Level - 1", 0, (255, 255, 255))
        game_screen_5.blit(label1, (300, 110))

        for e in pygame.event.get():
            if e.type == pygame.QUIT:
                pygame.quit()
            if e.type == pygame.MOUSEMOTION and pygame.mouse.get_pressed()[0]:
                mx, my = pygame.mouse.get_pos()
                # Deciding colour based on mouse position
                if ((mx in range(130, 170) and my in range(130, 170))
                        or (mx in range(180, 220) and my in range(330, 370))):
                    circ = 1  #RED
                elif ((mx in range(230, 270) and my in range(130, 170))
                      or (mx in range(180, 220) and my in range(280, 320))):
                    circ = 2  #GREEN
                elif ((mx in range(230, 270) and my in range(180, 220))
                      or (mx in range(230, 270) and my in range(330, 370))):
                    circ = 3  #BLUE
                elif ((mx in range(330, 370) and my in range(130, 170))
                      or (mx in range(280, 320) and my in range(280, 320))):
                    circ = 4  #YELLOW
                elif ((mx in range(330, 370) and my in range(180, 220))
                      or (mx in range(280, 320) and my in range(330, 370))):
                    circ = 5  #ORANGE

                # If the colour is RED
                if (circ == 1):
                    if (mx in range(125, 175) and my in range(ra, rb)
                            and my not in range(325, 350)):
                        pygame.draw.line(game_screen_5, RED, (150, ra - 25),
                                         (150, rb - 25), 20)
                        if (my not in range(325, 375)):
                            ra += 50
                            rb += 50
                        else:
                            continue
                    elif (mx in range(rc, rd) and my in range(325, 375)):
                        pygame.draw.line(game_screen_5, RED, (rc - 34, 350),
                                         (rd - 25, 350), 20)
                        if (done_r == 0):
                            done_r = 1
                            flow += 1
                    if (mx in range(rc, rd) and my in range(325, 375)):
                        pygame.draw.line(game_screen_5, RED, (rd - 25, 350),
                                         (rc - 34, 350), 20)
                    elif (mx in range(125, 175) and my in range(rg, rf)):
                        pygame.draw.line(game_screen_5, RED, (150, rf + 25),
                                         (150, rg + 25), 20)
                        if (my not in range(125, 175)):
                            rg -= 50
                            rf -= 50
                        else:
                            if (done_r == 0):
                                done_r = 1
                                flow += 1
                            continue
                #GREEN
                elif (circ == 2):
                    if (mx in range(ga, gb) and my in range(125, 175)):
                        pygame.draw.line(game_screen_5, GREEN, (gb + 25, 150),
                                         (ga + 16, 150), 20)
                    elif (mx in range(175, 225) and my in range(gc, gd)):
                        pygame.draw.line(game_screen_5, GREEN, (200, gc - 34),
                                         (200, gd - 25), 20)
                        if (my not in range(275, 325)):
                            gc += 50
                            gd += 50
                        else:
                            if (done_g == 0):
                                done_g = 1
                                flow += 1
                            continue
                    if (mx in range(175, 225) and my in range(gf, gg)):
                        pygame.draw.line(game_screen_5, GREEN, (200, gg + 25),
                                         (200, gf + 25), 20)
                        if (my not in range(125, 175)):
                            gf -= 50
                            gg -= 50
                        else:
                            continue

                    elif (mx in range(gh, gi) and my in range(125, 175)):
                        pygame.draw.line(game_screen_5, GREEN, (gh - 34, 150),
                                         (gi - 25, 150), 20)
                        if (done_g == 0):
                            done_g = 1
                            flow += 1

                #BLUE
                elif (circ == 3):
                    if mx in range(225, 275) and my in range(ba, bb):
                        pygame.draw.line(game_screen_5, BLUE, (250, ba - 25),
                                         (250, bb - 25), 20)
                        if (my not in range(325, 375)):
                            ba += 50
                            bb += 50
                        else:
                            if (done_b == 0):
                                done_b = 1
                                flow += 1
                            continue
                    if mx in range(225, 275) and my in range(bc, bd):
                        pygame.draw.line(game_screen_5, BLUE, (250, bd + 25),
                                         (250, bc + 25), 20)
                        if (my not in range(175, 225)):
                            bc -= 50
                            bd -= 50
                        else:
                            if (done_b == 0):
                                done_b = 1
                                flow += 1
                            continue
                #YELLOW
                elif (circ == 4):
                    if (mx in range(ya, yb) and my in range(125, 175)):
                        pygame.draw.line(game_screen_5, YELLOW, (yb + 25, 150),
                                         (ya + 16, 150), 20)
                    elif (mx in range(275, 325) and my in range(yc, yd)):
                        pygame.draw.line(game_screen_5, YELLOW, (300, yc - 34),
                                         (300, yd - 25), 20)
                        if (my not in range(275, 325)):
                            yc += 50
                            yd += 50
                        else:
                            if (done_y == 0):
                                done_y = 1
                                flow += 1
                            continue

                    if (mx in range(275, 325) and my in range(yf, yg)):
                        pygame.draw.line(game_screen_5, YELLOW, (300, yg + 25),
                                         (300, yf + 25), 20)
                        if (my not in range(125, 175)):
                            yf -= 50
                            yg -= 50
                        else:
                            continue

                    elif (mx in range(yh, yi) and my in range(125, 175)):
                        pygame.draw.line(game_screen_5, YELLOW, (yh - 34, 150),
                                         (yi - 25, 150), 20)
                        if (done_y == 0):
                            done_y = 1
                            flow += 1

                #ORANGE
                elif (circ == 5):
                    if (mx in range(325, 375) and my in range(oa, ob)):
                        pygame.draw.line(game_screen_5, ORANGE, (350, oa - 25),
                                         (350, ob - 25), 20)
                        if (my not in range(325, 375)):
                            oa += 50
                            ob += 50
                        else:
                            continue
                    elif (mx in range(oc, od) and my in range(325, 375)):
                        pygame.draw.line(game_screen_5, ORANGE, (od + 34, 350),
                                         (oc + 25, 350), 20)
                        if (done_o == 0):
                            done_o = 1
                            flow += 1

                    if (mx in range(of, og) and my in range(325, 375)):
                        pygame.draw.line(game_screen_5, ORANGE, (og - 25, 350),
                                         (of - 16, 350), 20)
                    elif (mx in range(325, 375) and my in range(oh, oi)):
                        pygame.draw.line(game_screen_5, ORANGE, (350, oi + 34),
                                         (350, oh + 25), 20)
                        if (my not in range(175, 225)):
                            oh -= 50
                            oi -= 50
                        else:
                            if (done_o == 0):
                                done_o = 1
                                flow += 1
                            continue
        if (flow == 5):
            game_over()
            pygame.display.update()
            print str(flow)
        pygame.display.flip()