[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] A little help please
- To: pygame-users@xxxxxxxx
- Subject: [pygame] A little help please
- From: Silver <rockachu2@xxxxxxxxx>
- Date: Sat, 14 Jan 2012 20:40:59 -0800
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Sat, 14 Jan 2012 23:41:10 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :x-enigmail-version:content-type; bh=nQCdcz50VNkn03yinKUW4wO0UtpxNHIwqbL5lb6jjLY=; b=bnwMDSHquZqtJ8b2BRW+UiZ1rKOOTU6cPFzNQkGkydwGPJ0Xy1em4AEGsO0NWg08vs yoiiRYo+BlQ8TWhMX1Ro6EGoURL+qDxoJzq8Enzj8lbJDyUYpPkkc7Q+kIx7QQpDKohC rsmRg4T0A/OLLAcIk5c93SG/ZN7yYYWqWJ48U=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
- User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0) Gecko/20111222 Thunderbird/9.0.1
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()