0

I have a game and I need to know what colour is under the player's feet but when I use surf.get_at_(x, y), it gives me white instead of blue or green.

Any help would be appreciated, Thanks!

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
  • 3
    Please post a [minimal, complete and verifiable example](https://stackoverflow.com/help/mcve). – skrx Jul 09 '18 at 17:36
  • 1
    Remember, you need to use get_at on the surface that has the color. For example, you could do `screen.get_at(x,y)` or `player.get_at(x,y)`. Also, make sure that you are doing this **after** things have been drawn on the surface. If you do `screen.fill([255,255,255])` and then immediately try to `screen.get_at(x,y)` it **will** always return white, because the whole surface is white! – Luke B Jul 10 '18 at 15:10

1 Answers1

0

The argument for get_at() must be a tuple with the coordinate pair. See to documentation of pygame.Surface.get_at:

get the color value at a single pixel

get_at((x, y)) -> Color

Use a tuple with the coordinates instead of two separate arguments:

surf.get_at_(x, y)

surf.get_at_((x, y))
Rabbid76
  • 202,892
  • 27
  • 131
  • 174