I am 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?
If you donβt find this, I donβt see an easy way to do it - you, of course, start with a world map, - this is a good starting point on Wikipedia: http://upload.wikimedia.org/wikipedia/commons/0/03/ BlankMap-World6.svg
- Ah, according to your comments, you have a map drawn - Yes .. If all you need is to get color per click, it's easier - Choose the coordinates of the mouse click for the mouse 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))
If each country has a different color, and you know it, you can 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()
Hope this helps solve your problem.
Source: https://habr.com/ru/post/1332910/More articles:Volume keys - androidIs using Javascript eval () 100% safe? - javascriptIn Perl, how can I correctly parse tab / space delimited files with quoted strings? - splitReading open processes / list of applications in Java? - javaCan you call the WCF service from a SQL Server 2008 query? - sqlC # multithreading - multithreadingCan someone explain this bit of HtmlAgilityPack code? - c #Method overload - javaGetting album art like JPEG, PNG, etc. - javaHow to find which range is in - javaAll Articles