
We import pygame and some other local modules, then use the init method on pygame to start our game or start pygame. This game like many early classics has its roots in the arcades of the 70s it was first released to the public in 1976 by a company called gremlin under the name of blockade two years later it entered the world of computers with there lease of worms for the micro computers 18 from there the game spread to nearly all personal computers and adopted its lasting name of google snake as there was no one single owner of the game versions of it were created for nearly all major consoles and that is. Next, we set up our game window, or tell pygame to initialize our game window with _mode() method passing in our screen dimensions in a tuple (? The reason we need this is that pygame creates a game window and we need to declare the width and height of it, you can choose any width and height, I am choosing 800圆00) We make two variables or constants, WIN_X and WIN_Y to store our screen dimensions or our screen width and screen height, In the end, I just set up a caption or label for the game window using _caption() method passing in the caption string, you can pass any string you want here ?.

Now if you run this code, you will see the game screen for a short time, and then it exits the program. Ĭan you guess why this happens ?, well cause we didn't define any game loop. Ī game loop is just an infinite loop, that goes on forever until the user exits or closes it. Let's go ahead and implement our game loop As we didn't define any game loop, the window was visible for a moment, but then the program ended, and so the game screen was also gone.

#The FPS or frame per second or more explicitly set_caption ( 'snake game' ) #initializing () which controls init () WIN_X = 800 WIN_Y = 600 WIN = pygame.
