Pygame Movimiento
# -*- coding: utf-8 -*-
import pygame
import random
import time
def dibujar_lluvia(window, limites, listaPuntos):
for i in range(len(listaPuntos)):
r = listaPuntos[i][2]
x = listaPuntos[i][0]
y = listaPuntos[i][1]
pygame.draw.circle(window,(255,255,255), [x, y], r, 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, 640)
y = random.randrange(0, 600)
listaPuntos.append([x, y, radio])
return listaPuntos
pygame.init()
running = True
window = pygame.display.set_mode( (640,600) )
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
listaPuntos = crearPuntosAletorios(15, [640,600])
dibujar_lluvia(window, [640, 600], listaPuntos)
# cuerpo
pygame.draw.polygon(window, (255, 128, 64),
[(110, 50), (190, 50), (190, 130), (230, 130), (230, 250), (190, 250), (190, 330), (110, 330),
(110, 250), (70, 250), (70, 130), (110, 130), (110, 50)], 0)
# cara
pygame.draw.polygon(window, (128, 64, 0),
[(110, 50), (190, 50), (190, 80), (180, 80), (180, 70), (120, 70), (120, 80), (110, 80),
(110, 50)], 0)
pygame.draw.polygon(window, (255, 255, 255), [(120, 90), (130, 90), (130, 100), (120, 100), (120, 90)], 0)
pygame.draw.polygon(window, (128, 0, 128), [(130, 90), (140, 90), (140, 100), (130, 100), (130, 90)], 0)
pygame.draw.polygon(window, (128, 0, 128), [(160, 90), (170, 90), (170, 100), (160, 100), (160, 90)], 0)
pygame.draw.polygon(window, (255, 255, 255), [(170, 90), (180, 90), (180, 100), (170, 100), (170, 90)], 0)
pygame.draw.polygon(window, (128, 0, 0), [(140, 100), (160, 100), (160, 110), (140, 110), (140, 100)], 0)
pygame.draw.polygon(window, (128, 0, 0), [(130, 110), (170, 110), (170, 120), (130, 120)], 0)
# playera
pygame.draw.polygon(window, (0, 0, 255),
[(70, 130), (130, 130), (130, 140), (140, 140), (140, 150), (160, 150), (160, 140), (170, 140),
(170, 130), (230, 130), (230, 170), (190, 170), (190, 250), (180, 250), (180, 240), (170, 240),
(170, 230), (110, 230), (110, 170), (70, 170), (70, 130)], 0)
# pantalones
pygame.draw.polygon(window, (128, 0, 128), [(110, 230), (150, 230), (150, 310), (110, 310), (110, 230)], 0)
pygame.draw.polygon(window, (128, 0, 128),
[(150, 230), (170, 230), (170, 240), (180, 240), (180, 250), (190, 250), (190, 310), (150, 310),
(150, 230)], 0)
# zapatos
pygame.draw.polygon(window, (192, 192, 192), [(110, 310), (150, 310), (150, 330), (110, 330), (110, 310)], 0)
pygame.draw.polygon(window, (192, 192, 192), [(150, 310), (190, 310), (190, 330), (150, 330), (150, 310)], 0)
pygame.display.update()
pygame.display.quit()
import pygame
import random
import time
def dibujar_lluvia(window, limites, listaPuntos):
for i in range(len(listaPuntos)):
r = listaPuntos[i][2]
x = listaPuntos[i][0]
y = listaPuntos[i][1]
pygame.draw.circle(window,(255,255,255), [x, y], r, 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, 640)
y = random.randrange(0, 600)
listaPuntos.append([x, y, radio])
return listaPuntos
pygame.init()
running = True
window = pygame.display.set_mode( (640,600) )
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
listaPuntos = crearPuntosAletorios(15, [640,600])
dibujar_lluvia(window, [640, 600], listaPuntos)
# cuerpo
pygame.draw.polygon(window, (255, 128, 64),
[(110, 50), (190, 50), (190, 130), (230, 130), (230, 250), (190, 250), (190, 330), (110, 330),
(110, 250), (70, 250), (70, 130), (110, 130), (110, 50)], 0)
# cara
pygame.draw.polygon(window, (128, 64, 0),
[(110, 50), (190, 50), (190, 80), (180, 80), (180, 70), (120, 70), (120, 80), (110, 80),
(110, 50)], 0)
pygame.draw.polygon(window, (255, 255, 255), [(120, 90), (130, 90), (130, 100), (120, 100), (120, 90)], 0)
pygame.draw.polygon(window, (128, 0, 128), [(130, 90), (140, 90), (140, 100), (130, 100), (130, 90)], 0)
pygame.draw.polygon(window, (128, 0, 128), [(160, 90), (170, 90), (170, 100), (160, 100), (160, 90)], 0)
pygame.draw.polygon(window, (255, 255, 255), [(170, 90), (180, 90), (180, 100), (170, 100), (170, 90)], 0)
pygame.draw.polygon(window, (128, 0, 0), [(140, 100), (160, 100), (160, 110), (140, 110), (140, 100)], 0)
pygame.draw.polygon(window, (128, 0, 0), [(130, 110), (170, 110), (170, 120), (130, 120)], 0)
# playera
pygame.draw.polygon(window, (0, 0, 255),
[(70, 130), (130, 130), (130, 140), (140, 140), (140, 150), (160, 150), (160, 140), (170, 140),
(170, 130), (230, 130), (230, 170), (190, 170), (190, 250), (180, 250), (180, 240), (170, 240),
(170, 230), (110, 230), (110, 170), (70, 170), (70, 130)], 0)
# pantalones
pygame.draw.polygon(window, (128, 0, 128), [(110, 230), (150, 230), (150, 310), (110, 310), (110, 230)], 0)
pygame.draw.polygon(window, (128, 0, 128),
[(150, 230), (170, 230), (170, 240), (180, 240), (180, 250), (190, 250), (190, 310), (150, 310),
(150, 230)], 0)
# zapatos
pygame.draw.polygon(window, (192, 192, 192), [(110, 310), (150, 310), (150, 330), (110, 330), (110, 310)], 0)
pygame.draw.polygon(window, (192, 192, 192), [(150, 310), (190, 310), (190, 330), (150, 330), (150, 310)], 0)
pygame.display.update()
pygame.display.quit()
Comentarios
Publicar un comentario