[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Shooting an image



> ----- Original Message -----
> From: "Kris Schnee" <kschnee@xxxxxxxxxx>
> To: pygame-users@xxxxxxxx
> Subject: Re: [pygame] Shooting an image
> Date: Mon, 13 Oct 2008 18:55:32 +0000
> 
> 
> On Tue, 14 Oct 2008 02:49:11 +0800, "yanom @linuxmail.org"
> <yanom@xxxxxxxxxxxxx> wrote:
> > I have this chunk of code that's should make the player shoot a torpedo,
> as
> > long as their isn't another torpedo on the screen and the player has the
> > space key down. Why dosen't this work:
> >
> > 		
> >
> >                 if key[K_SPACE] and torpedorect.top < -600:
> > 			torpedorect.left = playerrect.left
> > 			torpedorect.top = playerrect.top
> > 		else:
> > 			torpedorect = torpedorect.move(0,-7)##############
> 
> Could you please post more context, such as the specific error message or
> what you see?
> 
> I surmise that you've got a "torpedo" object whose location is defined by
> "torpedorect," and that you're getting "key" by calling "key =
> pygame.keyboard.get_pressed()" to get a table of what keys are currently
> being held down. You seem to be recycling the same torpedo by just changing
> its location when it's re-fired rather than spawning a new one, which was
> the topic of some jokes earlier about "bullet theology."
> 
> Not sure why you're doing it this way. Why should you have to hold the key
> down to fire instead of just pressing it? And doesn't this code move the
> torpedo to be right on top of the player, causing a collision if it's
> checked for, and probably a moment of weirdly overlapping graphics?

>
1)I don't see any error messages, but the space key won't make the torpedo fire.
2)both of your assumptions are correct
3)yes I am recycling the same bullet. Why was this the topic of some jokes? I'm new to pygame and that was probably before i joined the mailinglist.
4)i was trying to make the space key move the torpedo back to the spawnpoint, so I saw that as the easiest way.
5)I decided to move the bullet on top of the player because:
           a:: I am just making this game to test my skills, I don't care about how the graphics look
           b:: It is not checking for a collision between playerrect(the player) and torpedorect(the bullet)
           c:: It's the easier than trying to find a place to spawn it that looks good.

=
Tokyo Hostels
Book a Hotel in Tokyo, Japan.
http://a8-asy.a8ww.net/a8-ads/adftrclick?redirectid=ebb1a5a6e61c0a1660e5a977602b745f


-- 
Powered by Outblaze