Created
December 16, 2014 06:50
-
-
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.
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 | |
| #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