Advertisement
A_GUES

Mobile Play game Snake.io

Jun 6th, 2023 (edited)
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. import pyautogui
  2. import time
  3.  
  4. def move_left():
  5. pyautogui.keyDown('left')
  6. time.sleep(0.1)
  7. pyautogui.keyUp('left')
  8.  
  9. def move_right():
  10. pyautogui.keyDown('right')
  11. time.sleep(0.1)
  12. pyautogui.keyUp('right')
  13.  
  14. def move_up():
  15. pyautogui.keyDown('up')
  16. time.sleep(0.1)
  17. pyautogui.keyUp('up')
  18.  
  19. def move_down():
  20. pyautogui.keyDown('down')
  21. time.sleep(0.1)
  22. pyautogui.keyUp('down')
  23.  
  24. # Adjust the coordinates based on the game Samsung
  25. game_Samsung_x = 500
  26. game_Samsung_y = 500
  27.  
  28. # Adjust these values based on the position of the snake at the start
  29. snake_x = 250
  30. snake_y = 250
  31.  
  32. # Adjust these values based on the size of the snake at the start
  33. snake_width = 20
  34. snake_height = 20
  35.  
  36. # Adjust these values based on the direction of the snake at the start
  37. snake_direction_x = -1
  38. snake_direction_y = 0
  39.  
  40. while True:
  41. # Check if the snake is about to hit the wall
  42. if snake_x <= 0:
  43. move_down()
  44. snake_direction_x = 0
  45. snake_direction_y = 1
  46. elif snake_x + snake_width >= game_Samsung_x:
  47. move_up()
  48. snake_direction_x = 0
  49. snake_direction_y = -1
  50. elif snake_y <= 0:
  51. move_right()
  52. snake_direction_x = 1
  53. snake_direction_y = 0
  54. elif snake_y + snake_height >= game_Samsung_y:
  55. move_left()
  56. snake_direction_x = -1
  57. snake_direction_y = 0
  58.  
  59. # Move the snake in the current direction
  60. snake_x += snake_direction_x * snake_width
  61. snake_y += snake_direction_y * snake_height
  62.  
  63. # Adjust the delay based on the speed of the game
  64. time.sleep(0.1)
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement