Thursday, 15 September 2011

python - Get 1 pixel RGB color in pygame -



python - Get 1 pixel RGB color in pygame -

how can 1 pixel rgb color in 2d game? need compare reddish color(255,0,0), need (r,g,b). tried utilize get_at() method this:

if background.get_at(x,y) == (255,0,0): print("same") else: print("not same")

but didn't worked.

code:

import pygame pygame.init() background = pygame.display.set_mode([640,480]) background_colour = (3, 3, 251) background.fill(background_colour) pygame.display.flip() print(background.get_at(2,2)) if background.get_at(background(2,2)) == background_colour: print("same") else: print("not same:")

error:

traceback (most recent phone call last): file "c:/users/kaspar/desktop/proov13.py", line 8, in <module> print(background.get_at(2,2)) typeerror: function takes 1 argument (2 given)

python colors pygame rgb

No comments:

Post a Comment