[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Fwd: [Tutor] A more Pythonic way to do this
- To: pygame-users@xxxxxxxx
- Subject: Re: [pygame] Fwd: [Tutor] A more Pythonic way to do this
- From: "D. Hartley" <denise.hartley@xxxxxxxxx>
- Date: Wed, 6 Jul 2005 11:28:59 -0700
- Delivered-to: archiver@seul.org
- Delivered-to: pygame-users-outgoing@seul.org
- Delivered-to: pygame-users@seul.org
- Delivery-date: Wed, 06 Jul 2005 14:29:13 -0400
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=uQ6ZhmjoDOpGKqSfBnAaY51EpcgfgZONqjrOhLnp6qkyF5aocHaz8S8IYLnysIfARzunHCk0D/SFZXSLdLun8aJlOjmJ4H+xyT9IdDNzcdgWlUBf/LYS8PvZl39iP7E7PMdELldodx5c9yjwovxrg1Wj1/SJNV5t3eL+nvU7Ngk=
- In-reply-to: <Pine.LNX.4.56.0507061336460.10587@twobox.geeky.net>
- References: <8daabe5605063015111d32477a@mail.gmail.com> <42C5B888.6000708@po-box.mcgill.ca> <8daabe5605070115567afb6c39@mail.gmail.com> <42C5CC7D.4070705@po-box.mcgill.ca> <8daabe5605070117216b20c08a@mail.gmail.com> <be4fbf9205070206397f35dfed@mail.gmail.com> <8daabe56050705115964075b58@mail.gmail.com> <be4fbf9205070515584d510fd9@mail.gmail.com> <8daabe5605070516351857d85e@mail.gmail.com> <Pine.LNX.4.56.0507061336460.10587@twobox.geeky.net>
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
Shandy,
Thanks, that was the push in the right direction I was looking for. Now I have:
for enemy in (enemyship_sprites.sprites()):
print enemy.initialx, enemy.initialy
enemy.rect.centerx = enemy.initialx
enemy.rect.centery = enemy.initialy
However.... when it prints the initialx, initialy, it's giving me 0,0
- the initial default value for initialx, initialy in the Enemy's
init, which is updated with the new value when the enemies are
created:
Enemy.initialx = (cols*60)+20
Enemy.initialy = (rows*40)+30
enemyship_sprites.add(Enemy(Enemy.initialx, Enemy.initialy, level))
print Enemy.initialx,
print Enemy.initialy
At this point, it does give me all of the different coordinates for
the different starting points for each ship. But then when I take my
current set of ships-that-havent-been-killed-yet
(enemyship_sprites.sprites()), when it looks at each, it's now telling
me initialx/initialy is 0/0.
Any idea why? I can send the full code if it's necessary to see the
progression of steps.
~Denise
On 7/6/05, Shandy Brown <sjbrown@xxxxxxxxx> wrote:
> >
> > for each in (enemyship_sprites.sprites()):
> > each.rect.centerx = Enemy.initialx
> > each.rect.centery = Enemy.initialy
>
> Hi Denise.
>
> This code above is the part where you're using initialx and initialy as
> class attributes. You probably want something like
>
> each.rect.centerx = each.initialx
>
> instead.
>
> -sjbrown
>