Skip to content

Instantly share code, notes, and snippets.

@jonaslsaa
Created December 16, 2014 06:50
Show Gist options
  • Select an option

  • Save jonaslsaa/48020fa60b0bc941ed2e to your computer and use it in GitHub Desktop.

Select an option

Save jonaslsaa/48020fa60b0bc941ed2e to your computer and use it in GitHub Desktop.
A Windows Paint Remake (Simple). UP/DOWN Arrow to adjust brush size. BACKSPACE to erase everything.
import pygame
#Initialization
pygame.init()
print("> SuperGGPaint Debug Console")
print("")
#Defining colors
white = (255,255,255)
black = (0,0,0)
red = (255,0,0) #RGB
green = (0,155,0)
blue = (0,0,255)
cyan = (0,220,220)
mouse_black = (0,0,0,25)
#Display
display_size = (800,600)
display_width = display_size[0]
display_height = display_size[1]
gameDisplay = pygame.display.set_mode(display_size)
clock = pygame.time.Clock()
title = "SuperGGPaint"
pygame.display.set_caption(title)
font_size = 30
font = pygame.font.SysFont(None, font_size)
def img(brush_size, color, imglist):
for XnY in imglist:
pygame.draw.rect(gameDisplay, color, [XnY[0],XnY[1],brush_size,brush_size])
def appLoop():
#Game Loop
appExit = False
#Defining Varibles
brush_size = 10
brush_color = black
imgList = []
mouseDown = False
while not appExit: #Main Loop
brush_pos_x = pygame.mouse.get_pos()[0]
brush_pos_y = pygame.mouse.get_pos()[1]
for event in pygame.event.get():
#print(event)
#print(pygame.mouse.get_pos()[1])
if event.type == pygame.QUIT:
appExit = True
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_UP:
brush_size += 5
print("Set brush size bigger!")
elif event.key == pygame.K_DOWN:
brush_size -= 5
print("Set brush size smaller!")
elif event.key == pygame.K_BACKSPACE:
imgList = []
if event.type == pygame.MOUSEBUTTONDOWN:
mouseDown = True
elif event.type == pygame.MOUSEBUTTONUP:
mouseDown = False
#Drawing to gameDisplay
gameDisplay.fill(white) #Drawing Background
imgHead = []
imgHead.append(brush_pos_x)
imgHead.append(brush_pos_y)
if mouseDown == True:
imgList.append(imgHead)
pygame.draw.rect(gameDisplay, brush_color, [brush_pos_x,brush_pos_y,brush_size,brush_size])
img(brush_size, brush_color, imgList)
pygame.display.update() #Updates Game
pygame.quit()
quit()
appLoop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment