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

Re: [pygame] Function for keyboard movement



Hi Bob,

There are a lot of ways to do it..

In the past, I've used something like this for teaching basic movement:

This should work fine for objects that won't move fast enough to cover more than a tile per frame..

Is that what you were looking for? Or something even more abstracted like..

while True:
  tts = fpcClock.tick( FPS )

  held_keys = update_keys()

  draw_background()

  update_sprites( tts, held_keys )

  draw_sprites()

  pygame.display.update()

Thank you,
Noel

On Tue, Oct 6, 2015 at 4:12 PM, Bob Irving <bobirv@xxxxxxxxx> wrote:
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