Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help with game
You can use multiple keys. One for you and one for others.
# moving ship
    get_key = lambda key: Game.keys_press.get(key, False)
    if get_key('a') or get_key('Left'):
        Game.canvas.move(Game.ship, -Game.ship_speed, 0)
    if get_key('d') or get_key('Right'):
        Game.canvas.move(Game.ship, Game.ship_speed, 0)
    if get_key('w') or get_key('Up'):
        Game.canvas.move(Game.ship, 0, -Game.ship_speed)
    if get_key('s') or get_key('Down'):
        Game.canvas.move(Game.ship, 0, Game.ship_speed)
    if Game.keys_press.get('space', False):
        if pauser_elaspe(Game.shoot_pauser, Game.ticks):
If you don't know lambda does. It makes a quick simple function.
get_key = lambda key: Game.keys_press.get(key, False)
equal to
def get_key(key):
    return Game.keys_press.get(key, False)
hammza likes this post
99 percent of computer problems exists between chair and keyboard.
Thank you :)

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  [PyGame] Game Logic problem with a "The Game of Life" Replication Coda 2 251 Dec-24-2018, 09:26 AM
Last Post: Coda

Forum Jump:

Users browsing this thread: 1 Guest(s)