Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Character Control using Python

Tags:

python

I was wondering if anyone knows how to import a sprite and let it move when pressing the arrow keys in python, without using pygame, or some other library. This is purely out of curiosity, because I was just thinking about some sort of personal challenge, and that's what came to mind: a python game, without the help of pygame or libtcod. Is this possible, or do you need a library to do this for you? I'd appreciate anyone's input on this one.

Thanks.

like image 689
Jeremy Darrach Avatar asked Mar 01 '26 09:03

Jeremy Darrach


1 Answers

What comes to my mind is using Tkinter's Canvas class. It is quite possible to do a simple program like that described using bindings on this class.

A good example of this may be found in Mark Lutz's Programming Python (http://shop.oreilly.com/product/9780596158118.do), the Moving Pics example.

If you don't own this, you can still look at the code for it as a reference by downloading the code using the link on the right side of the page. The path to the appropriat folder is /PP4E-Examples-1.3.1/Examples/PP4E/Gui/MovingPics/.

like image 186
pydsigner Avatar answered Mar 03 '26 22:03

pydsigner