[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Working with maps
- To: pygame-users@xxxxxxxx
- Subject: Re: [pygame] Working with maps
- From: Kenny Meyer <knny.myer@xxxxxxxxx>
- Date: Tue, 18 May 2010 10:27:36 -0400
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Tue, 18 May 2010 10:28:10 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:subject :message-id:mail-followup-to:references:mime-version:content-type :content-disposition:in-reply-to:user-agent:x-gpg-fingerprint :x-website; bh=kYjxsrCvnn8b3XFXS7TelD2/UJbEeH5qh1JLYIJwopM=; b=aRFUdq4pbfkpdAjx3JL1vi5ZbzoZsNmyk3RM8laEjfwv8+3uqnoC8dalL8onoDn1Xb x2NiYdX4Ne7IdvhmRFvGDU+nU9bDAqJ+KkWk/MeNbNsVi2yPBKTIyUP+pdBKR0KovU3h 6hKD6PB7sQu9EsAMG0FlZwpeL9A19IGDbpRJc=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition:in-reply-to :user-agent:x-gpg-fingerprint:x-website; b=uF4Ff7nLeA5PLeoPOelgaQqxs3rzku3tjYb+lbLHdrmca2KK4qkVnQKTKXO2SFfkYP E/PzBlFDHaLTEWN8yDCVYSPl0FO53CUb2bDGhUack0PDOtk97w2h/pGaoAzvaUDxS5/D F9oW8BJLFRmlM+otO4g8VWmGRE+8aOdjlpmBk=
- In-reply-to: <4BF249A9.7070807@xxxxxxxxxxxxx>
- Mail-followup-to: pygame-users@xxxxxxxx
- References: <20100518040912.GA2428@5732Z> <4BF249A9.7070807@xxxxxxxxxxxxx>
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
- User-agent: Mutt/1.5.20
Timothy Baldock (tb@xxxxxxxxxxxxx) wrote:
> Hi Kenny,
>
> I'd do this by making each country a sprite with a transparent
> background (colour-key transparency would work), then whenever the user
> clicks doing a collision detection between the position of the mouse
> cursor (first use rect-collision to build a small number of tiles which
> match, then do pixel-perfect collision based on alpha - i.e. using the
> sprite's mask). Easiest way to do this IMO is to draw an "invisible"
> (e.g. position the sprite, but don't actually draw it to the screen)
> 1x1px sprite at the position of the mouse cursor, then collide that
> against the group containing all the country sprites.
>
> This technique means the countries can be any colour you want, or the
> colour can change without messing things up. I used this method for my
> isometric game engine to allow selection of tiles and other objects and
> found it to be quite fast.
>
> Thanks,
>
> Timothy
>
>
> On 18/05/2010 05:09, Kenny Meyer wrote:
> > Hey,
> >
> > I'd like to work with irregular formed geometric shapes like those in of
> > country maps in pygame.
> >
> > I want to do the following:
> > "Divide" a country map into its states and provinces and make each of them
> > "click-able", where the map could be an image (*.png) or maybe a vector graphic
> > (*.svg).
> >
> > The result should be:
> > A game where to guess and click the name of the state and province on a map.
> >
> > Observations:
> > It would be quite difficult to assign each state/province fixed coordinates as
> > those are irregular geometric shapes.
> >
> > Any ideas, pointers to other projects or suggestions?
> >
>
Timothy,
Thank you for your answer!
> I'd do this by making each country a sprite with a transparent
> background (colour-key transparency would work), then whenever the user
> clicks doing a collision detection between the position of the mouse
> cursor (first use rect-collision to build a small number of tiles which
> match, then do pixel-perfect collision based on alpha - i.e. using the
> sprite's mask). Easiest way to do this IMO is to draw an "invisible"
> (e.g. position the sprite, but don't actually draw it to the screen)
> 1x1px sprite at the position of the mouse cursor, then collide that
> against the group containing all the country sprites.
I get the idea and I also think I will try this. Do you have any concrete
examples of this in action?
--
Regards,
Kenny Meyer