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

[pygame] A bunch of newbie questions



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