Pages

Wednesday, February 26, 2014

pygame grid

#Trying to make a sprite drawing program... click on the squares/rects
#make a sprite, save image.  Haven't figured out it all yet. Just a grid.
 # the actual GRID is only 4 lines of code plus the variables.  I'll mark em.


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

pygame.init()
#############  GRID VARIABLES ########
WINDOWWIDTH = 800
WINDOWHEIGHT = 800
CELLSIZE = 10
CELLWIDTH = int(WINDOWWIDTH/CELLSIZE)
CELLHEIGHT = int(WINDOWHEIGHT/CELLSIZE)
#####################################
#always rainbows.    
x1 = random.randint(0, 255)
y1 = random.randint(10, 245)
z1 = random.randint(15, 200)
   
RAINBOW1 = (x1, y1, z1)
GREY = (200, 200, 200)
BLUE = (0, 0, 255)
BLUE1 = (0, 0, 230)
BLUE2 = (50, 0, 250)
RED = (210, 0, 0)
RED2 = (255, 20, 50)
WHITE = (255, 250, 250)
GREEN = (0, 255, 0)
BLACK = (0, 0, 0)



pygame.init()
   


SCREEN = pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT))   
SCREEN.fill((255, 255, 255))

pygame.display.update()
clock = pygame.time.Clock

z = 0

FONT = pygame.font.Font('freesansbold.ttf', 18)
pygame.display.set_caption("Make a Sprite")   
######################GRID ###########################
     
for x in range(0, WINDOWWIDTH, CELLSIZE):
    pygame.draw.line(SCREEN, BLACK, (x, 0), (x, WINDOWHEIGHT))
for y in range(0, WINDOWHEIGHT, CELLSIZE):
    pygame.draw.line(SCREEN, BLACK, (0, y), (WINDOWWIDTH, y))   

#######################GRID##########################

while True:
   
    (a,b) = pygame.mouse.get_pos()

    for event in pygame.event.get():
        if event.type == QUIT:
            sys.exit()
       
   

No comments:

Post a Comment