[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Background ghosts
- To: pygame-users@xxxxxxxx
- Subject: Re: [pygame] Background ghosts
- From: "Jake b" <ninmonkeys@xxxxxxxxx>
- Date: Fri, 2 Jan 2009 04:47:22 -0600
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Fri, 02 Jan 2009 05:47:27 -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:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=YeGHq4AUGbjiuziPwBp+BHi0cVYlX9P9vjwNqwUFnSk=; b=JbV+Uvsuzlx+g6BjK/HuI5O4zj+Awus9qwRI02rawoL+rgTpvWbnA7LfXKOIuaUeGR GR4lTym5cnek9sR9/P0vVzmyYD4tpiUWEdY5Vqd0gAoVrl+dBkKrtMgh9cPPeZJ92+Dt 0cypxe+0JIZCMawVUGD/LjhpSgl/sRhHoQcbM=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=j8jHKNgJYXZ7JnTniwAB9Brr+nlTKou5b8prV+0dJs6TWsAKZFoKYhQR0DOxksMrhE QhKOr14YdtupnToVKRqF0R+L47Nucv01bDAV1RwIRmef74h33h255kc8vUhqaMrjLvHc V+gjryHkuJSffKNW9c5n3qAGoSQgXI++Qaink=
- In-reply-to: <20090101140123.13364@xxxxxxxxxxxxxxxxxxxxx>
- References: <20090101140123.13364@xxxxxxxxxxxxxxxxxxxxx>
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
>As for the splitting the sprites, I considered that. The problem is that when a row is complete (just like in >Tetris), a whole piece that fell wouldn't necessarily disappear, but only part of one. I guess I could separate >each piece into multiple sprites, but that would involve dozens of sprites and I don't think that the tracking >of it would be any better than what I have right now.
It might make collisions, and lining up of colors easier you you did
it something like this:
Have a Block() object for each of the 'squares' that makes up a
Piece. So the line actually spawns 3 Blocks() right after another, so
it looks like one object. I would find that easier to do collisions
for the more complicated shapes --- unless you are already doing it
this way.
-----
I ran the program, and see it. I tried finding the problem, but I'm
not sure where it is. ( seems kinda random when it does or not show
up. )
I think it's time to re-factor your code. It would make it a lot
clearer, and you'll probably fix the problem in the process.
You might want to grab the shootorial py code I just posted on the
mailing list to use as a template. Then fill in your upate() and
draw() code.
The code includes class Text() which auto-manages a bunch of
pygame.font related things. ( loads font, only re-renders text if
something has changed, etc... )
This lets you do something like:
def loop()
"""Doing a single loop like this, then branching your 'draw' and
'update' functions based on mode can make it clearer to navigate"""
if mode == 'titlescreen':
self.text.text = "Rastras"
self.text.size = 32
do_titlescreen_event_handling()
draw_titlescreen()
elif mode == "game":
self.text.text = score
self.text.size = 16
do_game_event_handling()
draw_game()
def draw_titlescreen():
self.text.draw()
#draw buttons, etc...
def draw_titlescreen():
self.text.draw()
#draw blocks, etc....
# ie: you can do repeated calls to set text to "Rastras", yet it only
needs to render the text once, and blits the cached surface.
--
hope that helps,
Jake