Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # clouds with pygame
- # Import Libraries
- import pygame, sys
- from pygame.locals import *
- pygame.init()
- import math
- from random import randint
- DarkBlue = (0,153,255)
- Grey1 =(142, 150, 163)
- Mist1 = (213, 216, 222)
- Pink1 =(255, 230, 234)
- White1 = (255,255,255)
- def draw_cloud(x, y, l, h):
- if y > 200:
- col = Grey1
- elif y > 170:
- col = Mist1
- elif y < 130:
- col = Pink1
- else:
- col = White1
- pygame.draw.ellipse(mainDisplay, col, [x, y, l, h])
- def polar(r, theta):
- pi = 3.1415927
- ang = theta * pi /180
- yn = int(r*math.sin(ang)) + 200
- xn = int(r*math.cos(ang)) + 200
- return xn, yn
- # Set up display area
- Width = 500
- Height = 500
- mainDisplay = pygame.display.set_mode((Width,Height))
- mainDisplay.fill(DarkBlue)
- pygame.display.set_caption('Clouds')
- # Main section
- # mid cloud
- for loop in range(10):
- ll = randint(30,70)
- hh = randint(30,70)
- th0 = randint(180,360)
- rr = randint(10,80)
- coords = polar(rr, th0)
- draw_cloud(coords[0], coords[1], ll, hh)
- # mid cloud
- for loop in range(150):
- ll = randint(10,30)
- hh = randint(10,30)
- th0 = randint(180,360)
- rr = randint(30,100)
- coords = polar(rr, th0)
- draw_cloud(coords[0], coords[1], ll, hh)
- # outer cloud
- for loop in range(300):
- ll = randint(2,10)
- hh = randint(2,10)
- th0 = randint(180,360)
- rr = randint(55,100)
- coords = polar(rr, th0)
- draw_cloud(coords[0], coords[1], ll, hh)
- # under cloud
- for loop in range(100):
- ll = randint(2,10)
- hh = randint(2,10)
- th0 = randint(0,180)
- rr = randint(30,60)
- coords = polar(rr, th0)
- draw_cloud(coords[0], coords[1], ll, hh)
- while True: # main game loop
- for event in pygame.event.get():
- if event.type == QUIT:
- pygame.quit()
- sys.exit()
- pygame.display.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement