Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help with game
#31
No, I didn't changed any thing

And this exact problem is in all the codes

They all work perfectly, but just up+left not working. Haha

Really weird :)
Reply
#32
Try with all keys binding to the canvas not root window.
99 percent of computer problems exists between chair and keyboard.
Reply
#33
Still the same problem
Reply
#34
Try changes arrows keys wasd.
# moving ship
    if Game.keys_press.get('a', False):
        Game.canvas.move(Game.ship, -Game.ship_speed, 0)
    if Game.keys_press.get('d', False):
        Game.canvas.move(Game.ship, Game.ship_speed, 0)
    if Game.keys_press.get('w', False):
        Game.canvas.move(Game.ship, 0, -Game.ship_speed)
    if Game.keys_press.get('s', False):
        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()
99 percent of computer problems exists between chair and keyboard.
Reply
#35
Now it works correctly
Reply
#36
Sounds like a keyboard error.
99 percent of computer problems exists between chair and keyboard.
Reply
#37
Can you tell me about where can I find a good tutorial about tkinter and bindings with detail

Hhhhhh

I don't understand.

Maybe it about the version of python!!!

I use 3.6

Even with 3.5 and 2.7.12


Has the same problem
Reply
#38
i use python 3.6. Arrows keys and wasd keys should work the same. So sound like need test with another keyboard. To see if you get same results.

I use this PDF .
99 percent of computer problems exists between chair and keyboard.
Reply
#39
Here a small key press and release program example
import tkinter as tk

class App:
    pass
    
def event_press(event):
    if App.texts.get(event.keysym, False) is False:
        App.texts[event.keysym] = tk.Label(App.frame, text='Key Press ' + event.keysym)
        App.texts[event.keysym].pack()
    else:
        App.texts[event.keysym]['text'] = 'Key Press ' + event.keysym

    
def event_release(event):
    # numlock
    if event.keysym.startswith('KP') and event.char != '':
        key = 'KP_' + event.char
    else:
        key = event.keysym
        
    if App.texts.get(key, False):
        App.texts[key]['text'] = 'Key Release ' + key
    
def main():
    App.SCREEN_SIZE = {'w':600, 'h':400}
    App.root = tk.Tk()
    App.frame = tk.Frame(App.root, width=App.SCREEN_SIZE['w'], height=App.SCREEN_SIZE['h'])
    App.frame.pack()
    App.texts = {}
    App.frame.bind_all('<KeyPress>', event_press)
    App.frame.bind_all('<KeyRelease>', event_release)
    App.root.mainloop()
    
if __name__ == '__main__':
    main()    
    
99 percent of computer problems exists between chair and keyboard.
Reply
#40
Thank you for the ebook


Iam using laptop "azerty" keyboard, I don't have USB keyboard
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020