Last active
November 15, 2015 23:39
-
-
Save AndyNovo/cbfdfd0e0b64e45aee87 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) #These tuples are RGB by the way | |
WHITE = (255, 255, 255) | |
pygame.init() | |
WIDTH = 450 | |
HEIGHT = 600 | |
screen = pygame.display.set_mode([WIDTH, HEIGHT]) | |
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 | |
if pygame.mouse.get_pressed()[0]: | |
text = font.render("Hi there", 1, RED) #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, texty = pygame.mouse.get_pos() | |
pygame.draw.circle(screen, RED, (circle_x, circle_y), 30) | |
circle_y = (circle_y + 5) % HEIGHT | |
#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