[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] A bunch of newbie questions
- To: pygame-users@xxxxxxxx
- Subject: [pygame] A bunch of newbie questions
- From: "Miguel Sicart" <mundial82@xxxxxxxxx>
- Date: Mon, 26 Nov 2007 18:53:43 +0100
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Mon, 26 Nov 2007 12:53:52 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type; bh=uVHtiexW48dXkNiAVstNoOHEus8UWaUr3bHopVV0bRQ=; b=YOVS5ZlbDiifascohKidhjkuhbcglK+N150AlhVT9o0v4lnEhNnnZBRxwcoeQcyQ5sxL5hyUuZbi6tOXeX/sJ8i4pCPnzTtOtQeTWcXWtm0lJ68Z+hd4ln25PKLRQ6CkdsvnGnA0Bf/DBWVOu8c66cFKsLMdpnjVNn2yTaEj200=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=received:message-id:date:from:to:subject:mime-version:content-type; b=G3ZB9bUG+/TiLCaNuIbfhaVHbYUTBi8vpQOSsg6QVUzDgz9eYbtZi1K94MmXl3xINYbbGsyJzPvAiJpRDaN1zpKSKqfMvaqkrSmLehiyDCgSYvntfVV4/q4D8wS9dHk5c8cIFmd9aix3fYkXN/yYQWteEr+cVgIDl8/z3D4zAew=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
Hi all,
First of all - this email has a collection of basic, newbie questions. I hope this doesn't break etiquette or it's too annoying - if these are too many questions, or too basic (and there is somewhere else I could find answers), please let me know :)
On to the questions.
I am not a programmer, and only recently I took up Python/Pygame. While Object Orientation does not seem conceptually quite hard, I think the implementation puzzles. So here's the question:
I have a class that defines the main object with a keyboard method (among others) that controls player input
class Hero(pygame.sprite.Sprite)
def keyboard(self)
I have another object called companion, which just moves around the Hero
What I want is that, when the player presses space, a new object companion is created, up to for. So, how do I do that? Sprites are in groups in the main loop, but how do I append/add an instance to a group from the class.
In other words: how do I access the main loop from an object's method? (if that is possible).
Another question:
I am making a Every Extend clone to learn the magic of pygame. I have some trouble with two things:
1. The chain reaction - I am using rect.inflate, but it seems to be quite unprecise. Is it just better to load a new image, a "explosion", with a different rect, instead of inflating the original's rect?
2. Dying: as someone said, dying is easy, comedy is hard. OK, so when the hero dies, I need to kill the sprite, make a timer, and then instantiate it again. And I have no clue how to do any of these things (well, except self.(kill)). I am not fishing for code here, but for how to think about how to solve this problem.
I hope I have been at least a bit clear. Thanks to those who reach here and have read the text :) and thanks in advance for the help!
cheers,
Naranjito the Newbie