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

Re: [pygame] Function for keyboard movement



if it's of any use have a look at the code here.

https://bitbucket.org/pygame-arcade/the_spiritual_warrior

On Wed, Oct 7, 2015 at 11:27 AM, Renà Dudfield <renesd@xxxxxxxxx> wrote:
Hi Bob,

The smaller number of concepts used the better.

Try not to require defining functions or classesÂwhen explaining events.



Print the events out in the event loop. So people can see what events come in when they do things. TheÂevent example that comes with pygameÂis nice to showÂall the eventsÂon the screen.

Then you have to make the x, y axis concept clear. Draw the axis with labels on the screen.

Just use one rect and the screen.fill method to start, since this is the minimum you need to explain the concept. Make sure to print out the rect each time around the loop. They can see when adding 1 to the x of the rect that it moves over. They know what state the x is in for the rect.

Print at each stage, 'clearing buffer with screen.flip'.

Put a sleep in there at each point so they can see things slowly happening. When they press a key, they see an event happen, and know where it is in the code.

Sleep also helps giveÂthemÂsome idea of how it is a machine that takes time to do things. How there is a queue of events waiting from when you press a key, until when you ask for them. How there is a flow to the execution.


Hope that helps!



Happy hacking.



Am Dienstag, 6. Oktober 2015 schrieb Bob Irving :
Hi folks,

We're introducing Python for 9th grade this year and moving from Blitz Basic for game programming. Just wondering if anyone has come up with a way to hide the complexity for keyboard movement..... it's one of those things that makes sense to more advanced programmers but not to beginners. We've experimented with making a few functions to detect collisions, mouse clicks....

TIA,
Bob Irving
Porter-Gaud School
Charleston, SC



--
Diliup Gabadamudalige

http://www.diliupg.com
http://soft.diliupg.com/

**********************************************************************************************
This e-mail is confidential. It may also be legally privileged. If you are not the intended recipient or have received it in error, please delete it and all copies from your system and notify the sender immediately by return e-mail. Any unauthorized reading, reproducing, printing or further dissemination of this e-mail or its contents is strictly prohibited and may be unlawful. Internet communications cannot be guaranteed to be timely, secure, error or virus-free. The sender does not accept liability for any errors or omissions.
**********************************************************************************************