Bottom Page

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 :)
Quote
#32
Try with all keys binding to the canvas not root window.
hammza likes this post
99 percent of computer problems exists between chair and keyboard.
Quote
#33
Still the same problem
Quote
#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()
hammza likes this post
99 percent of computer problems exists between chair and keyboard.
Quote
#35
Now it works correctly
Quote
#36
Sounds like a keyboard error.
99 percent of computer problems exists between chair and keyboard.
Quote
#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
Quote
#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.
Quote
#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()    
    
hammza likes this post
99 percent of computer problems exists between chair and keyboard.
Quote
#40
Thank you for the ebook


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

Top Page

Forum Jump:


Users browsing this thread: 1 Guest(s)