#import pygame import pygame import random #initialize game engine pygame.init() window_width=500 window_height=500 no_of_circles=100; clock_tick_rate=20 #Open a window size = (window_width, window_height) screen = pygame.display.set_mode(size) #Set title to the window pygame.display.set_caption("Hello World") dead=False #Initialize values for color (RGB format) WHITE=(255,255,255) RED=(255,0,0) GREEN=(0,255,0) BLUE=(0,0,255) BLACK=(0,0,0) snow_list=[] for i in range(no_of_circles): x = random.randrange(0, window_width) y = random.randrange(0, window_height) snow_list.append([x,y]) clock = pygame.time.Clock() while(dead==False): for event in pygame.event.get(): if event.type == pygame.QUIT: dead = True screen.fill(BLACK) for point in snow_list: point[1]+=1 pygame.draw.circle(screen, WHITE, point, 2) if(point[1] >= window_height): point[0] = random.randrange(0, window_width) point[1] = random.randrange(-10, -5) pygame.display.flip() clock.tick(clock_tick_rate)
This blog is primarily focus on Java fundamentals and the libraries built on top of Java programming language. Most of the post are example oriented, hope you have fun in reading my blog....:)
Tuesday 8 December 2015
Pygame: Snow Animation
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment