[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] Invisible Pygame Car!?



MBr8473501@aol.com wrote:

> I'm working on a driving/shooting game. The car however won't show up on 
> the screen. When it did show up, i could only move it a few pixels left 
> and right, instead of the width of the screen. I'm thinking of making 
> the road image, part of the background. Any suggestions/comments will be 
> appreciated. Most of the code is taken from the Aliens example, and I've 
> learned a lot about updating rectangles in the process. Thanks in 
> advance, and here's the code...


ok, i admit, you had me stumped on this one (for awhile).
but then i deduced the problem. warning, here's a snip
from the code that may cause a self inflicted forehead slap.

<SNIP>
   while 1:
        # Initialize Game Actors
        player = Player()
</SNIP>


heh, so what's wrong here? you are creating a new "Player"
for every single frame. that means the old one is lost and
a new one is created in the center for every single frame.
this is why the player only seems to move one step to the
right or left.


the player did show up in my version, but i'm guessing
maybe you were drawing the "road" images on top of the
player? in the end you might want to make the road a
part of the background. it could be more flexible to not
put it in the background, but it will be more work for
you. for example, when you "erase()" a sprite, you are
erasing it with the background image (green), so you
will really need to erase it with green and/or the road
image, depending on where the cars are driving (off the
pavement?) anyways, if the road is in the background
image, then it won't matter. you'll just have to decide
if you want the flexibility.





____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org