Re: [pygame] a little help

2012-01-15 Thread Zack Baker
That email brings me too a question I've had for awhile now. What is better to 
use pygame.display.flip() or pygame.display.update()?

-Zack


On Jan 14, 2012, at 11:48 PM, Silver rockac...@gmail.com wrote:

 Oops, got my rect width argument wrong... Never mind.


Re: [pygame] a little help

2012-01-15 Thread Rastagong
pygame.display.update() affects only a part of the screen, whereas
pygame.display.flip() updates the whole screen. Therefore, using update()
can increase the perfs of your game.

However, if you update many parts of the screen at the same time (for
instance when you use scrolling, or when you load a full map) it becomes
totally useless. It only makes the screen shine during each update, and it
is pretty annoying to see.

So you have to think about the accurate moment to use update(). I would
suggest calling this function when you update a single surface.

Rastagong

2012/1/15 Zack Baker zbaker1...@gmail.com

 That email brings me too a question I've had for awhile now. What is
 better to use pygame.display.flip() or pygame.display.update()?

 -Zack


 On Jan 14, 2012, at 11:48 PM, Silver rockac...@gmail.com wrote:

  Oops, got my rect width argument wrong... Never mind.



Re: [pygame] a little help

2012-01-15 Thread Sean Wolfe
good info, thanks. I'm going to experiment with them both.

On Sun, Jan 15, 2012 at 1:18 PM, Rastagong rayman3...@gmail.com wrote:
 pygame.display.update() affects only a part of the screen, whereas
 pygame.display.flip() updates the whole screen. Therefore, using update()
 can increase the perfs of your game.

 However, if you update many parts of the screen at the same time (for
 instance when you use scrolling, or when you load a full map) it becomes
 totally useless. It only makes the screen shine during each update, and it
 is pretty annoying to see.

 So you have to think about the accurate moment to use update(). I would
 suggest calling this function when you update a single surface.

 Rastagong


 2012/1/15 Zack Baker zbaker1...@gmail.com

 That email brings me too a question I've had for awhile now. What is
 better to use pygame.display.flip() or pygame.display.update()?

 -Zack


 On Jan 14, 2012, at 11:48 PM, Silver rockac...@gmail.com wrote:

  Oops, got my rect width argument wrong... Never mind.





-- 
A musician must make music, an artist must paint, a poet must write,
if he is to be ultimately at peace with himself.
- Abraham Maslow


[pygame] A little help please

2012-01-14 Thread Silver
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 = .001#print nz
n = radius / nz
if n == 0:
n = .001
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()


[pygame] a little help

2012-01-14 Thread Silver
Oops, got my rect width argument wrong... Never mind.