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

Re: [pygame] Advice on turning sprite (newbie)





On Mon, Oct 26, 2009 at 6:25 AM, AdamC <kabads@xxxxxxxxx> wrote:
I'm learning pygame (also trying to teach my sons in the ins and outs
of python) and am trying to write a small simple game where a tank
moves around the screen on the user's press of the cursor keys. I've
managed to get this working without the tank turning and without using
an object oriented approach. However, I'm now trying to get my tank
working using the following tutorial [0]. My sprite appears on the
screen and the function move_me is called and changes the value of
draw_pos. However, the tank doesn't move.

It doesn't move on the screen or it doesn't rotate?  Did you break the movement when you made it OO?
What is your specific problem?

 

I'll also appreciate any general pointers about bad code, bad style
and any tips of how to more efficiently write this code.
After we figure out what you're doing we can figure out how to do it more efficiently.
As for style, your __init__ method is incredibly hard to read due to the weird indentation you have.  You need to stick to a specific level of indentation, i.e. the body of your __Init__ method should be 8 spaces in, because it is inside of a class and a method.  Also don't double-space code, you can leave blank lines to logically group different operations but double-spacing it just makes it less dense and harder to see what's going on.  Also in blit_me the comments should all be aligned with the body of the function.
 

Thanks in advance
Adam

[0] http://eli.thegreenplace.net/2008/12/13/writing-a-game-in-python-with-pygame-part-i
[1] http://dpaste.com/112074/
[2] http://dpaste.com/112075/