I need some help with a program that I'm trying to write with pygame. I am having two issues: * the squares aren't being drawn 1 px small so that they leave a black grid * the squares on the edges are extending, even though I don't think I told them to.
anyone know how to fix it?
import pygame import math squaresize = 64 sqsz = squaresize width = 799 height = width radius = .5*sqsz pygame.init() screen = pygame.display.set_mode((width,height)) while True: pygame.event.get() mousex = pygame.mouse.get_pos()[0] mousey = pygame.mouse.get_pos()[1] screen.fill((0,0,0)) for x in xrange(width/squaresize): for y in xrange(height/squaresize): hx = x hy = y hx *= sqsz hy *= sqsz #print hx,hy,sqsz, sqsz nx = hx+(sqsz/2)-mousex ny = hy+(sqsz/2)-mousey nz = ((nx**2)+(ny**2))**.5 if nz == 0: nz = .0000001 #print nz n = radius / nz if n == 0: n = .0000001 if n > 1: n = 1 #print n color = n*255 #print (color,color,color) #print hx, hy, hx+15, hy+15 pygame.draw.rect(screen, (color,color,color), (hx,hy,hx+sqsz-1,hy+sqsz-1)) pygame.display.update()