Friday, April 4, 2014

03.31.2014 - 04.04.2014

This week, I made a basic calculator program (TI84) and a simple paint program in Python. Next week I hope to improve upon both of them.

import pygame, random, sys
from pygame.locals import *

WINDOWWIDTH=600
WINDOWHEIGHT=600
BACKGROUNDCOLOR=(255,255,255)
FPS=50
PLAYERMOVERATE=5

def terminate():
    pygame.quit()
    sys.exit()

pygame.init()
mainClock=pygame.time.Clock()
windowSurface=pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT))
pygame.display.set_caption('Paint')
pygame.mouse.set_visible(False)
windowSurface.fill(BACKGROUNDCOLOR)

down=False

BLUE=(0, 0, 255)

while True:
    moveLeft=moveRight=moveUp=moveDown=False

    while True:
        for event in pygame.event.get():
            if event.type==QUIT:
                terminate()

            if event.type==KEYDOWN:
                if event.key==K_ESCAPE:
                    terminate()
                if event.key==event.key==ord('x'):
                   windowSurface.fill(BACKGROUNDCOLOR) 

        if event.type==MOUSEBUTTONDOWN:
            down=True
        if event.type==MOUSEBUTTONUP:
            down=False

        if event.type==MOUSEMOTION and down:
            pygame.draw.circle(windowSurface,BLUE, (event.pos[0], event.pos[1]), 10, 0)


        #windowSurface.fill(BACKGROUNDCOLOR)
        pygame.display.update()

        mainClock.tick(FPS)

No comments:

Post a Comment