+ 4

kivy question (snake)

Can someone tht know kivy help me with this code? https://code.sololearn.com/cjr5xgekEE1k i dont know how to do the tail and use keyboards events in it

14th Nov 2018, 2:23 AM
I Am Arthur
I Am Arthur - avatar
6 Antworten
+ 3
For adding keyboard events you can just bind a function for on_key_down on the widget. You an do like this inside your widget class: #make sure you import Window from kivy.core.window and request a keyboard. # suppose your keyboard is in self.keyboard then do self.keyboard.bind(on_key_down= self.keydownFunc) #keydownFunc here def keydownFunc(self, keyboard, keycode, text, modifiers): #you can assign action using text but here I'm showing by using keycode #assign job for each keydown if keycode[1] == 'a': #do something elif keycode[1] == 'b': #do something elif keycode[1]== 'up': #something else
14th Nov 2018, 5:03 AM
đĘđ░ĐëđŞ đáđ░đŻđÂđ░đŻ
đĘđ░ĐëđŞ đáđ░đŻđÂđ░đŻ - avatar
+ 2
PyDan Shashi Ranjan Do u guys know how to do the tail? I will have to create more labels for this , right?
14th Nov 2018, 1:45 PM
I Am Arthur
I Am Arthur - avatar
+ 2
Queen Arthur I'm working with kivy these days but I think, it'll take some time for me to understand the working of your code in order to help you with some specific part.
14th Nov 2018, 1:54 PM
đĘđ░ĐëđŞ đáđ░đŻđÂđ░đŻ
đĘđ░ĐëđŞ đáđ░đŻđÂđ░đŻ - avatar
+ 1
Some widgets size are small, you can change them
14th Nov 2018, 5:48 AM
danvetio
danvetio - avatar
+ 1
I think you maybe follow this video. It simple and easy to learn Snake game https://www.youtube.com/watch?v=onfix2QrES8&feature=youtu.be
15th Nov 2018, 12:43 AM
danvetio
danvetio - avatar