Snake - Part 1: Creation

Draw a window

To display a game of any sorts, of course first you need a window to display your graphics in.
To achieve this is pretty simple actually.

First you need to initialize pygame by calling pygame.init().
Then you need to define the window by callling pygame.display.set_mode([SIZE],{FLAGS}).

A basic way to call it is pygame.display.set_mode((800,600)), 800 and 600 being height and width in pixels.

If you need a bit more options than just size, you can set some flags.
The flags are stored as a 32-bit bit mask but don’t worry you won’t have to remember every bit thanks to some variables and the logical or " | “.

You can find more Information about flags here

In my code I will do the follwing:

import pygame
pygame.display.set_mode((800,600), pygame.HWSURFACE | pygame.DOUBLEBUF)