Skip to content

Instantly share code, notes, and snippets.

@MrSimsek
Last active May 26, 2019 12:15
Show Gist options
  • Save MrSimsek/fd210ad9fc7cb6a0c36f1818df76cf18 to your computer and use it in GitHub Desktop.
Save MrSimsek/fd210ad9fc7cb6a0c36f1818df76cf18 to your computer and use it in GitHub Desktop.
Draw some shapes and make a simple brush with background music
import pygame
pygame.init()
pygame.mixer.music.load("music.mp3")
pygame.mixer.music.play()
screen_width = 800
screen_height = 600
white = (255, 255, 255)
black = (0, 0, 0)
red = (255, 0, 0)
green = (0, 255, 0)
blue = (0, 0, 255)
game_screen = pygame.display.set_mode((screen_width, screen_height))
game_screen.fill(black)
pygame.draw.line(game_screen, blue, (100, 200), (300, 500), 10)
pygame.draw.rect(game_screen, red, (400, 300, 25, 25))
pygame.draw.circle(game_screen, white, (150, 150), 80)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.mixer.music.stop()
pygame.quit()
quit()
mouse_position = pygame.mouse.get_pos()
mouse_click = pygame.mouse.get_pressed()
if mouse_click[0] == 1:
pygame.draw.circle(game_screen, white, (mouse_position[0], mouse_position[1]), 20)
pygame.display.update()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment