Bambi nevada
Código en pygame de la figura con polígonos, añadiendo un ciclo for:
La figura se deberá ver así, a excepción que los rombos se moverán:
import pygame
import random
blanco= (255, 255, 255)
colores=[(255, 255, 255),(0, 162, 232)]
Dimensiones = (450, 560)
def dibujarBAMBI(window):
#fondo
pygame.draw.rect(window, blanco, (0, 450, 560, 150), 0)
# Cabeza
# negro
pygame.draw.polygon(window, (0, 0, 0),
[(50, 170), (50, 120), (60, 120), (60, 100), (70, 100), (70, 90), (90, 90), (90, 80), (160, 80),
(160, 60), (170, 60), (170, 50), (190, 50), (190, 40), (230, 40), (230, 50), (240, 50),
(240, 80), (230, 80), (230, 90), (270, 90), (270, 100), (290, 100), (290, 110), (300, 110),
(300, 120), (310, 120), (310, 160), (300, 160), (300, 170), (290, 170), (290, 180), (280, 180),
(280, 190), (200, 190), (50, 170)], 0)
# beige
pygame.draw.polygon(window, (240, 230, 140),
[(70, 150), (140, 120), (180, 120), (270, 130), (270, 180), (210, 180), (210, 200), (200, 220),
(170, 250), (80, 250), (60, 240), (40, 220), (40, 200), (50, 180), (60, 170), (70, 150)], 0)
# barro
pygame.draw.polygon(window, (210, 106, 30),
[(30, 200), (30, 220), (40, 220), (40, 230), (50, 230), (50, 240), (60, 240), (60, 250),
(80, 250), (80, 260), (110, 260), (110, 300), (120, 300), (120, 330), (130, 330), (130, 350),
(140, 350), (140, 360), (150, 360), (150, 370), (160, 370), (160, 380), (170, 380), (170, 370),
(160, 370), (160, 360), (150, 360), (150, 350), (140, 350), (140, 330), (130, 330), (130, 300),
(120, 300), (120, 260), (170, 260), (170, 250), (180, 250), (180, 240), (190, 240), (190, 230),
(200, 230), (200, 220), (210, 220), (210, 200), (220, 200), (220, 190), (250, 190), (250, 180),
(280, 150), (280, 140), (270, 140), (270, 130), (260, 130), (260, 120), (210, 120), (210, 130),
(200, 130), (200, 140), (210, 140), (210, 130), (260, 130), (260, 140), (270, 140), (270, 150),
(280, 150), (250, 180), (210, 180), (210, 200), (200, 200), (200, 220), (190, 220), (190, 230),
(180, 230), (180, 240), (170, 240), (170, 250), (80, 250), (80, 240), (60, 240), (60, 230),
(50, 230), (50, 220), (40, 220), (40, 200), (30, 200)], 0)
# blanco
pygame.draw.polygon(window, (255, 255, 255),
[(220, 50), (190, 50), (190, 60), (170, 60), (170, 80), (160, 80), (160, 90), (140, 100),
(110, 100), (110, 90), (90, 90), (90, 110), (110, 110), (110, 100), (130, 100), (130, 110),
(140, 110), (140, 120), (90, 120), (90, 130), (80, 130), (80, 140), (70, 140), (70, 150),
(130, 150), (130, 140), (140, 140), (140, 120), (210, 110), (230, 110), (230, 100), (210, 100),
(210, 110), (140, 120), (140, 100), (160, 90), (170, 90), (170, 70), (190, 70), (190, 60),
(220, 60), (220, 60)], 0)
# cafemarrom
pygame.draw.polygon(window, (250, 133, 63),
[(70, 100), (70, 120), (60, 120), (60, 170), (50, 170), (50, 180), (60, 180), (60, 170),
(70, 170), (70, 140), (80, 140), (80, 130), (90, 130), (90, 120), (100, 120), (100, 110),
(90, 110), (90, 100), (70, 100)], 0)
pygame.draw.rect(window, (250, 133, 63), (180, 120, 30, 10), 0)
pygame.draw.polygon(window, (250, 133, 63),
[(290, 120), (300, 120), (300, 160), (290, 160), (290, 170), (280, 170), (280, 180), (250, 180),
(250, 170), (260, 170), (260, 160), (270, 160), (270, 150), (280, 150), (280, 140), (290, 140),
(290, 120)], 0)
# cafe
pygame.draw.polygon(window, (139, 69, 19),
[(200, 100), (190, 100), (180, 100), (180, 90), (170, 90), (170, 70), (190, 70), (190, 60),
(220, 60), (220, 50), (230, 50), (230, 80), (220, 80), (220, 90), (200, 90), (200, 100),
(200, 110), (180, 110), (180, 100), (160, 100), (160, 90), (110, 90), (110, 110), (100, 110),
(100, 120), (130, 120), (130, 100), (140, 100), (140, 110), (130, 110), (130, 120), (260, 120),
(260, 130), (270, 130), (270, 140), (290, 140), (290, 110), (270, 110), (270, 100), (230, 100),
(230, 110), (210, 110), (210, 100), (200, 100)], 0)
# nariz
# negro
pygame.draw.rect(window, (0, 0, 0), (20, 170, 30, 30), 0)
# cafe
pygame.draw.rect(window, (139, 69, 19), (30, 180, 10, 10), 0)
# OJO
# Negro
pygame.draw.polygon(window, (0, 0, 0),
[(140, 160), (140, 170), (110, 170), (110, 180), (100, 180), (100, 190), (90, 190), (90, 220),
(100, 220), (100, 230), (130, 230), (130, 220), (160, 220), (160, 210), (170, 210), (170, 170),
(180, 170), (180, 160), (140, 160)], 0)
# Blanco
pygame.draw.polygon(window, (255, 255, 255),
[(100, 200), (100, 190), (110, 190), (130, 180), (160, 180), (160, 210), (150, 210), (150, 220),
(140, 220), (100, 200)], 0)
# celeste
pygame.draw.rect(window, (100, 149, 237), (100, 210, 30, 10), 0)
# Azul
pygame.draw.polygon(window, (0, 0, 205),
[(100, 210), (100, 200), (110, 200), (110, 180), (130, 180), (130, 190), (140, 190), (140, 220),
(130, 220), (130, 210)], 0)
# cuerpo
# MARRON
pygame.draw.polygon(window, (250, 133, 63),
[(160, 450), (150, 450), (150, 480), (140, 480), (140, 500), (120, 500), (120, 450), (130, 450),
(130, 450), (140, 450), (140, 360), (150, 360), (150, 370), (160, 370), (160, 450), (160, 480),
(150, 480), (150, 500), (180, 500), (180, 470), (190, 470), (190, 430), (200, 430), (200, 380),
(210, 380), (210, 350), (220, 350), (260, 320), (270, 340), (270, 370), (280, 380), (280, 430),
(270, 470), (270, 500), (310, 500), (330, 420), (330, 420), (340, 400), (360, 400), (360, 480),
(350, 480), (350, 500), (400, 500), (400, 430), (420, 430), (420, 370), (390, 370), (390, 360),
(360, 210), (340, 190), (340, 260), (250, 300), (140, 260), (130, 260), (130, 290), (145, 340),
(170, 370), (170, 450), (160, 450)], 0)
# NEGRO
pygame.draw.polygon(window, (0, 0, 0),
[(130, 350), (130, 450), (120, 450), (120, 480), (110, 480), (110, 500), (120, 500), (120, 510),
(180, 510), (180, 500), (190, 500), (190, 470), (200, 470), (200, 430), (210, 430), (210, 380),
(200, 380), (200, 430), (190, 430), (190, 470), (180, 470), (180, 500), (150, 500), (150, 480),
(160, 480), (160, 450), (170, 450), (170, 380), (160, 380), (160, 450), (150, 450), (150, 480),
(140, 480), (140, 500), (120, 500), (120, 480), (130, 480), (130, 450), (140, 450), (140, 350),
(130, 350)], 0)
pygame.draw.polygon(window, (0, 0, 0),
[(260, 340), (260, 370), (270, 370), (270, 380), (280, 380), (280, 430), (270, 430), (270, 470),
(260, 470), (260, 500), (270, 500), (270, 510), (310, 510), (310, 500), (320, 500), (320, 460),
(330, 460), (330, 420), (340, 420), (340, 400), (360, 400), (360, 450), (350, 450), (350, 480),
(340, 480), (340, 500), (350, 500), (350, 510), (390, 510), (390, 500), (400, 500), (400, 470),
(410, 470), (410, 430), (420, 430), (420, 410), (430, 410), (430, 380), (420, 380), (420, 370),
(410, 370), (410, 360), (390, 360), (390, 370), (410, 370), (410, 380), (420, 380), (420, 410),
(410, 410), (410, 430), (400, 430), (400, 470), (390, 470), (390, 500), (350, 500), (350, 480),
(360, 480), (360, 450), (370, 450), (370, 390), (340, 390), (340, 380), (320, 380), (320, 370),
(310, 370), (310, 360), (300, 360), (300, 350), (290, 350), (290, 340), (280, 340), (280, 350),
(290, 350), (290, 360), (300, 360), (300, 370), (310, 370), (310, 380), (320, 380), (320, 390),
(340, 390), (340, 400), (330, 400), (330, 420), (320, 420), (320, 460), (310, 460), (310, 500),
(270, 500), (270, 470), (280, 470), (280, 430), (290, 430), (290, 380), (280, 380), (280, 370),
(270, 370), (270, 340), (260, 340)], 0)
pygame.draw.polygon(window, (0, 0, 0),
[(160, 250), (160, 260), (170, 260), (170, 270), (180, 270), (180, 280), (200, 280), (200, 270),
(220, 270), (220, 260), (240, 260), (240, 250), (260, 250), (260, 240), (320, 240), (320, 250),
(340, 250), (340, 200), (350, 200), (350, 210), (360, 210), (360, 220), (370, 220), (370, 210),
(360, 210), (360, 200), (350, 200), (350, 190), (340, 190), (340, 180), (330, 180), (330, 240),
(320, 240), (320, 230), (260, 230), (260, 240), (240, 240), (240, 250), (220, 250), (220, 260),
(200, 260), (200, 270), (180, 270), (180, 260), (170, 260), (170, 250), (160, 250)], 0)
# cafe
pygame.draw.polygon(window, (139, 69, 19),
[(140, 260), (140, 270), (150, 270), (150, 280), (160, 280), (160, 290), (200, 290), (200, 300),
(320, 300), (320, 290), (330, 290), (330, 280), (340, 280), (340, 250), (320, 250), (320, 240),
(260, 240), (260, 250), (240, 250), (240, 260), (220, 260), (220, 270), (200, 270), (200, 280),
(180, 280), (180, 270), (170, 270), (170, 260), (140, 260)], 0)
# beige
pygame.draw.rect(window, (240, 230, 140), (220, 270, 20, 20), 0)
pygame.draw.rect(window, (240, 230, 140), (260, 250, 20, 20), 0)
pygame.draw.rect(window, (240, 230, 140), (280, 270, 20, 20), 0)
pygame.draw.rect(window, (240, 230, 140), (290, 240, 20, 10), 0)
pygame.draw.polygon(window, (240, 230, 140),
[(370, 220), (370, 230), (380, 230), (380, 260), (370, 260), (370, 270), (380, 270), (380, 290),
(390, 290), (390, 330), (380, 330), (380, 350), (370, 350), (370, 340), (360, 340), (360, 220),
(370, 220)], 0)
pygame.draw.polygon(window, (240, 230, 140),
[(210, 360), (220, 360), (220, 350), (230, 350), (230, 340), (250, 340), (250, 330), (290, 330),
(290, 340), (300, 340), (300, 320), (290, 320), (290, 310), (260, 310), (260, 320), (240, 320),
(240, 330), (230, 330), (230, 340), (220, 340), (220, 350), (210, 350), (210, 360)], 0)
pygame.draw.polygon(window, (240, 230, 140),
[(120, 260), (120, 300), (130, 300), (130, 330), (140, 330), (140, 350), (150, 350), (150, 360),
(160, 360), (160, 370), (170, 370), (170, 350), (160, 350), (160, 340), (150, 340), (150, 320),
(140, 320), (140, 290), (130, 290), (130, 260), (120, 260)], 0)
# blanco
pygame.draw.polygon(window, (255, 255, 255),
[(150, 290), (150, 300), (160, 300), (160, 320), (170, 320), (170, 330), (180, 330), (180, 380),
(170, 380), (170, 420), (180, 420), (180, 380), (190, 380), (190, 350), (200, 350), (200, 340),
(210, 340), (210, 330), (200, 330), (200, 320), (190, 320), (190, 310), (170, 310), (170, 300),
(160, 300), (160, 290), (150, 290)], 0)
pygame.draw.polygon(window, (255, 255, 255),
[(320, 340), (330, 340), (330, 360), (340, 360), (340, 330), (330, 330), (330, 320), (320, 320),
(320, 340)], 0)
pygame.draw.polygon(window, (255, 255, 255),
[(350, 480), (350, 490), (360, 490), (360, 480), (370, 480), (370, 450), (380, 450), (380, 430),
(370, 430), (370, 450), (360, 450), (360, 480), (350, 480)], 0)
# barro
pygame.draw.polygon(window, (210, 106, 30),
[(210, 380), (220, 380), (220, 360), (230, 360), (230, 350), (250, 350), (250, 340), (290, 340),
(290, 330), (250, 330), (250, 340), (230, 340), (230, 350), (220, 350), (220, 360), (210, 360),
(210, 380)], 0)
pygame.draw.polygon(window, (210, 106, 30),
[(380, 360), (390, 360), (390, 330), (400, 330), (400, 290), (390, 290), (390, 270), (380, 270),
(380, 260), (390, 260), (390, 230), (380, 230), (380, 220), (370, 220), (370, 230), (380, 230),
(380, 260), (370, 260), (370, 270), (380, 270), (380, 290), (390, 290), (390, 330), (380, 330),
(380, 360)], 0)
def dibujar_Nevada(window, limites, listaPuntos):
for i in range(len(listaPuntos)):
r = listaPuntos[i][2]
x = listaPuntos[i][0]
y = listaPuntos[i][1]
color = random.choice(colores)
pygame.draw.circle(window, color , [x+2, y+2], r+2, 0)
#pygame.draw.polygon(window, blanco, [(x+1,y+3),(x+4,y+3),(x+5,y),(x+6,y+3),(x+9,y+3),(x+6.5,y+5),(x+7.5,y+8),(x+5,y+6),(x+2.5,y+8),(x+3.5,y+5)],0)
listaPuntos[i][1] += 1
if listaPuntos[i][1] > limites[1]:
y = random.randrange(-50, -10)
listaPuntos[i][1] = y
x = random.randrange(50, limites[0])
listaPuntos[i][0] = x
def crearPuntosAletorios(cantidad, rangos):
listaPuntos = []
for i in range(cantidad):
radio = 1
x = random.randrange(1, 450)
y = random.randrange(0, 560)
listaPuntos.append([x, y, radio])
return listaPuntos
def main():
pygame.init()
window = pygame.display.set_mode(Dimensiones)
pygame.display.set_caption("BAMBI INVIERNO")
game_over = False
reloj = pygame.time.Clock()
listaPuntos = crearPuntosAletorios(50, [450, 560])
while not game_over:
for evento in pygame.event.get():
if evento.type == pygame.QUIT:
game_over = True
window.fill((0,0,128))
#---Nevada------
dibujar_Nevada(window, [450, 560], listaPuntos)
#---Bambi---
dibujarBAMBI(window)
pygame.display.flip()
reloj.tick(60)
pygame.quit()
if __name__ == "__main__":
main()
Resultado
Comentarios
Publicar un comentario