[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] how hexcolour arrays works?



Hi, i'm having problems on defining a hexcolour array - weird is i
never have this kind of problem when defining a string array in the
same way...
This may look as a very naive mistake, but i got really stuck, since
even from google searches i can't get any help...
Thanks a lot in advance... :-)

import pygame,random
pygame.init()
a=[]*8  #- same as 'dim a[8]' from sdlBasic?
a[0]=0x883746;a[1]=0xA88721;a[2]=0xBDE87A;a[3]=0xEE875F   #- list
assignment index out of range?
a[4]=0xFE98A1;a[5]=0x334836;a[6]=0x374838;a[7]=0xAAB398
screen=pygame.display.set_mode((320,240));bkgd=pygame.Surface(screen.get_size());bkgd=bkgd.convert();bkgd.fill(a[random.random()*7])
pygame.display.set_caption("move a box")
box=pygame.Surface((25,25));box=box.convert();box.fill(a[random.random()*7])
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()