[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] Simple question



Alexander wrote:
I'm brazilian and I don't speak english, but I try.
hi alexander, i know we have at least one other user from brazil, so you might be able to get some portuguese help? for now you'll have to try reading my help.


Recently I decide write school games using python. But I never write games in any language.
games are a little different than most programs. it is sort of like writing programs with full UIs. the part that makes it hard is that no part of the game can take too long, or it makes the entire game stop.


I program in PHP, ASP, VB, Perl and C, but never with games.
since you have used these other languages, you should have no trouble learning python. there are many good tutorials, but if you just look at other people's programs you should learn enough to get started.


So, I need some help to start my first screen.
I just need create one screen with one color.
I can do this, but my screen stay blink all the time.
do you mean stays black? or is something blinking? in pygame, anytime you draw on the display Surface you need to tell pygame to update the screen. the simplest way is to call pygame.display.flip(), which will update the entire screen.

Somebody can send to me one example(with coments) about create one screen with some color(what module i need use, what functions, what make that functions).
here is the simplest example i can come up with to fill a window with a color. everytime the mouse is pressed it will change colors.

import pygame
from pygame.locals import *
def main():
#initialize
pygame.init()
size = 255, 255
window = pygame.display.set_mode(size)
#draw a color
color = 200, 100, 50
window.fill(color)
pygame.display.flip()
#wait for user to push buttons
while 1:
event = pygame.event.wait()
if event.type == QUIT:
return
elif event.type == MOUSEBUTTONDOWN:
color = event.pos[0], event.pos[1], 50
window.fill(color)
pygame.display.flip()
main()