rocket simulation game with just using tkinter

Irmen de Jong irmen.NOSPAM at xs4all.nl
Tue Oct 4 14:43:08 EDT 2016


On 4-10-2016 10:20, Christian Gollwitzer wrote:

> Thanks! It works now with the cursor keys as intended. I'm still having trouble, but
> only because my game playing skills are not very good ;)

Have you managed to land the rocket again at all after a takeoff?
You can practice landing a bit by touching down anywhere on the ground, for instance
just a little bit to the right of the starting launchpad.
The real challenge is of course to land it on the other launchpad without touchdowns in
between.


>> Also I've discovered that there seems to be an issue with some Tkinter versions; it
>> sometimes doesn't update the screen fast enough. On OSX this problem is not present but
>> it is on Python 2.7 on Windows for example. I don't know what is causing it or how to
>> fix it at this time.   The FPS counter in the top right of the window should say 30,
>> that is when the game is updating at the intended speed.
> 
> Maybe if the system is simply too slow for your intended speed ?

Python 2.7 on my windows box shows the slow update behavior, while Python 3.5 on the
same windows box runs fine at 30 fps (or even 60 if you tell it to).
I concluded that it is an implementation problem.

> I see that you are
> using after_idle if the delay is less than 1 ms. after_idle performs a different task
> than after. I think, instead you should skip frames, i.e. compute how many frames you
> are behind the clock and advance the physics by that and draw the next frame instead.
> Otherwise the delay might build up.

Yes you're right but the computer is not too slow I believe, see above.

> The drawing itself has also different speed on different system. And, the canvas is not
> intended to redraw everything on each frame. Instead, updating the objects using the
> coords() method is usually faster. (It should also be easier)

I didn't want to tie it too much to the implementation details of Tkinter canvases.
Usually I think games have some graphics area that has to be redrawn every frame.
That, and Tkinter canvas cannot rotate a polygon so I have to redraw the rocket anyway!

Thanks for your interest in this little game :)
Irmen




More information about the Python-list mailing list