Created
November 15, 2015 22:58
-
-
Save AndyNovo/92c73fe39779b3850a19 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame | |
import random | |
BLACK = (0,0,0) | |
RED = (255, 0, 0) | |
WHITE = (255, 255, 255) | |
pygame.init() | |
screen = pygame.display.set_mode([450, 600]) | |
another_loop = True | |
clock = pygame.time.Clock() | |
font = pygame.font.Font(None, 36) #Make a font | |
textx = 100 | |
texty = 400 | |
circle_x = 50 | |
circle_y = 50 | |
while another_loop: | |
# --- Basic Event Processing | |
for event in pygame.event.get(): | |
if event.type == pygame.QUIT: | |
another_loop = False | |
# Every loop we will wipe the screen and redraw images | |
screen.fill(BLACK) | |
text = font.render("Hi there", 1, WHITE) #Use font to generate text image | |
#Draw the new screen here: | |
screen.blit(text, (100, 100)) #stick that image on screen | |
screen.blit(text, (textx, texty)) #possibly in multiple places | |
textx = (textx + random.randint(-5, 5)) % 450 #make updates | |
texty = (texty + random.randint(-5, 5)) % 600 | |
pygame.draw.circle(screen, RED, (circle_x, circle_y), 30) | |
circle_y = (circle_y + 5) % 850 | |
#This sets the frames per second | |
clock.tick(60) | |
#This puts the new stuff you've drawn on screen | |
pygame.display.flip() | |
#When we've left the while loop exit pygame | |
pygame.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment