Reputation: 43
I'm creating a game with pygame and I need a map where the user can select a country by clicking on it.
Can someone help me?
Upvotes: 4
Views: 660
Reputation: 110271
Unless you find that done, I see no easy way of doing that -- You have to start by having a World map, of course -- this one in Wikipedia seems a nice starting point: http://upload.wikimedia.org/wikipedia/commons/0/03/BlankMap-World6.svg
--Ah, I see by your comments you have the map drawn -- Yes.if all you need is to get the color for a click, that is easier - Pick the click coordinates with the mouse event for the click:
e = pygame.event.poll()
if e == pygame.MOUSEBUTTONDOWN:
pos = e.pos
# where "screen" is your variable holding the screen surface color = screen.get_at((pos))
Upvotes: 4
Reputation:
If every country has another color and you know it, you could detect it with:
import pygame
pygame.init()
screen = pygame.display.set_mode([100,100])
print(screen.get_at([50,50]))#returns tuple with color values
pygame.quit()
I hope this helps to solve your problem
Upvotes: 0