Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help with game
#41
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):
            shoot()
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.
Quote
#42
Thank you :)
Quote

Top Page

Forum Jump:


Users browsing this thread: 1 Guest(s)