Pages

Wednesday, February 5, 2014

The internet is teaching me PYGAME!

import pygame
import random

from pygame.locals import*


def main():   
    pygame.init()
   

   
    (mouseX, mouseY) = pygame.mouse.get_pos()
       
    SCREEN = pygame.display.set_mode((800,800))
    pygame.display.set_caption('Nellie wants to be a Geek!')

    BACKGROUND = pygame.Surface(SCREEN.get_size())
    BACKGROUND = BACKGROUND.convert()
    BACKGROUND.fill((100,100,100))

    x = random.randint(0, 255)
    y = random.randint(10, 245)
    z = random.randint(15, 200)
    RAINBOW = (x, y, z)
    x1 = random.randint(0, 255)
    y1 = random.randint(10, 245)
    z1 = random.randint(15, 200)
    RAINBOW1 = (x1, y1, z1)
    BLACK = (0, 0, 0)
    WHITE = (255, 255, 255)
    PURPLE = (255, 0, 220)
    BLUE = (50, 50, 250)
   
    font = pygame.font.Font(None, 49)
    text = font.render("Pooping Unicorn! Clicky clicky!", False, RAINBOW)
    textPos = text.get_rect()
    textPos.centerx = BACKGROUND.get_rect().centerx
    BACKGROUND.blit(text, textPos)
   
   
   
    SCREEN.blit(BACKGROUND, (0,0))
    pygame.display.flip()


    while 1:   
       
        for event in pygame.event.get():
            if event.type == MOUSEBUTTONDOWN :
                (mouseX, mouseY) = pygame.mouse.get_pos()
                pygame.draw.circle(BACKGROUND, (RAINBOW1), (mouseX, mouseY) , 20, 20)
                x1 = random.randint(0, 255)
                y1 = random.randint(10, 245)
                z1 = random.randint(15, 200)
                RAINBOW1 = (x1, y1, z1)
            if event.type == QUIT:
                return   
        SCREEN.blit(BACKGROUND, (0,0))
        pygame.display.flip()
       

if __name__ == '__main__': main()

No comments:

Post a Comment