-
-
Save JeffersGlass/408753eb92d00ce355256802ad3a6760 to your computer and use it in GitHub Desktop.
This file contains 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 sys #will use the exit function | |
#Loads all the main pygame modules and initializes them | |
pygame.init() | |
screen_width=640 | |
screen_height=480 | |
#Red, Green, Blue | |
red = (255,0,0) | |
green = (0,255,0) | |
blue = (0,0,255) | |
cyan = (0,255,255) | |
magenta = (255,0,255) | |
yellow = (255,255,0) | |
#Create a new Surface with the dimensions listed above | |
screen=pygame.display.set_mode((screen_width, screen_height)) | |
#Loop forever: | |
while True: | |
#The following makes the window close when clicking the "X" or exit button | |
#Without this, the window will not close, and will need to be killed | |
#with the task manager | |
for event in pygame.event.get(): | |
if event.type == pygame.QUIT: sys.exit() | |
#(surface, color, center, radius) | |
pygame.draw.circle(screen, blue, (300, 200), 30) | |
#surface, color, start position, end position, width | |
pygame.draw.line(screen, yellow, (50,50), (75,400), 5) | |
myRectangle = pygame.Rect(50,100,200,300) #(left, top, width, height) | |
pygame.draw.rect(screen, red, myRectangle) #(Surface, color, Rect) | |
myElRect = pygame.Rect(150,300,45,90) | |
pygame.draw.ellipse(screen, green, myElRect) | |
#Apply all the changes we've made to the screen surface | |
#And draw them to the screen | |
#corners of a polygon | |
points = [(450,300),(400,300),(350,325),(350,275),(450,290)] | |
pygame.draw.polygon(screen, cyan, points) | |
myArcRect = pygame.Rect(500,100,100,100) | |
#surface, color, Rect, start angle, end angle, width | |
pygame.draw.arc(screen, magenta, myArcRect, 0, (3.14159/2), 10) | |
pygame.display.flip() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment