snake_x and snake_y: It is the coordinates of the snake in x and y direction.Once the variable is assigned True the python sanke game will be over. game_over: It is also initialized to False.Once the variable is True, we will exit from the game. game_exit: It is initialized to False.We define a game function in which various variables are initialized : Defining the variables that will be used in the program: def game():Īpple_x = random.randint(20,width_of_screen/2)Īpple_y = random.randint(20,height_of_screen/2) pygame.K_SPACE(): After clicking the space key, the python snake game will start.Ħ.pygame.KEYDOWN(): It checks whether a key is pressed or not.pygame.QUIT(): It checks whether we are in the game or not.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |