learnopencv icon indicating copy to clipboard operation
learnopencv copied to clipboard

Added Arrow key Capture to ease the game

Open azeemushanali opened this issue 3 years ago • 0 comments

New Feature added

Instead of just using the A,S,D,W we can also use the arrow keys. Which can be an another option to play game easily. While capturing the key using -
> `key = cv2.waitKey(int(1000/speed))`
We could use -
> `key = cv2.waitKeyEx(int(1000/speed))`
It will capture the whole value for the key pressed, and then in the key value check we can use these values to move snake in the up ,down ,left ,right. Here's something for reference -
  • Up Arrow Value --> 2490368
  • Down Arrow Value --> 2621440
  • Left Arrow Value --> 2424832
  • Right Arrow Value --> 2555904

Here's the gist to test the code and the values. [https://gist.github.com/azeemushanali/3ea50ba54048a533802c7b62c16528ba](Gist For Key Value Check)

azeemushanali avatar Oct 26 '20 20:10 azeemushanali