ejemplo pasar polygonos a pygame
El dia de hoy pasaremos el código del perrito que esta en tkinter a pygame
programa del perrito
El código nos quedaría de la siguiente manera:
# -*- coding: utf-8 -*- import pygame from pygame import K_ESCAPE pygame.init() window = pygame.display.set_mode((1200, 650)) pygame.display.set_caption("Perrito con pygame") window.fill(color= (128,128,128)) # cara pygame.draw.polygon(window, (210, 180, 140), [(415, 50), (235, 490), (365, 625), (755, 625), (850, 500), (700, 50)],0) # orejas pygame.draw.polygon(window, (210, 105, 30), [(415, 50), (60, 320), (175, 635)], 0) pygame.draw.polygon(window, (210, 105, 30), [(700, 50), (1045, 320), (896, 635)], 0) # menton pygame.draw.polygon(window, (210, 105, 30), [(365, 625), (550, 415), (755, 625)],0) # ojos pygame.draw.ellipse(window, (0, 0, 0),(420, 225, 60, 80),0) pygame.draw.ellipse(window, (0, 0, 0),(630, 225, 60, 80),0) # bigotes pygame.draw.ellipse(window, (0, 0, 0),(475, 525, 15, 15),0) pygame.draw.ellipse(window, (0, 0, 0),(615, 525, 15, 15),0) pygame.draw.ellipse(window, (0, 0, 0),(445, 560, 15, 15),0) pygame.draw.ellipse(window, (0, 0, 0),(610, 560, 15, 15),0) pygame.draw.ellipse(window, (0, 0, 0),(480, 560, 15, 15),0) pygame.draw.ellipse(window, (0, 0, 0),(640, 560, 15, 15),0) # nariz pygame.draw.ellipse(window, (0, 0, 0),(470, 305, 170, 195),0) pygame.display.update() #para poder terminar el evento o programa while True: for event in pygame.event.get(): if event.type == pygame.QUIT: exit() keyboard = pygame.key.get_pressed() if keyboard[K_ESCAPE]: exit()
y la figura de la siguiente manera:
Comentarios
Publicar un comentario