Paulo Silva wrote:
thanks, but i found nothing there... :-(
Annotated and style cleaned up. General note: Never put multiple statements on one line. Just pretend that ; doesn't exist.
import random import pygame pygame.init() # a=[]*8 #- same as 'dim a[8]' from sdlBasic? # No, this will just repeat an empty list 8 times, giving you another # empty list a = [None] * 8 # This is valid, but the following version is better a = [ 0x883746, 0xA88721, 0xBDE87A, 0xFE98A1, 0x334836, 0x374838, 0xAAB398, ] screen = pygame.display.set_mode((320,240)) pygame.display.set_caption("move a box") background = pygame.Surface(screen.get_size()).convert() background.fill(random.choice(a)) box = pygame.Surface((25,25)).convert() box.fill(random.choice(a)) box_x=0 box_y=100 clock = pygame.time.Clock() kpg = True while kpg: clock.tick(30) for event in pygame.event.get(): if event.type==pygame.QUIT: kpg=False box_x+=5 if box_x > screen.get_width(): box_x=0 screen.blit(bkgd, (0,0)) screen.blit(box, (box_x,box_y)) pygame.display.flip() There, isn't that easier to read? --Noah
Attachment:
signature.asc
Description: OpenPGP digital signature