

Add the events for Form1 that will enable us to draw the snake, its food, and to intercept keyboard messages: Private Sub Form1_Load(ByVal sender As Object, _īyVal e As System.EventArgs) Handles MyBase.Load When the snake dies, we have to display a message with the score and start the game again.

We feed the snake randomly until it dies. Private Sub DisplayMessage(ByVal strMsg As String)ĭim intScreenWidth As Integer = ((ClientRectangle.Width \ _ĭim intScreenHeight As Integer = ((ClientRectangle.Height \ _ĭim intX As Integer = rnd.Next(0, intScreenWidth)ĭim intY As Integer = rnd.Next(0, intScreenHeight) PntLocation.Y = CInt(rectBounds.Top / intStep) * intStep PntLocation.X = CInt(rectBounds.Left / intStep) * intStepĮlseIf (pntLocation.X rectBounds.Bottom) Then If (pntLocation.X > rectBounds.Right) Then

Public Sub Move(ByVal rectBounds As Rectangle, Optional ByVal _ĭirMove As intDirection = intDirection.None) If (dirMove = intDirection.None) Then dirMove = iDirection Public Sub Move(Optional ByVal dirMove As intDirection = _ If (dirNext = intDirection.None) Then dirNext = iDirection Add the following sub procedures: Public Function NextLoc(Optional ByVal dirNext _Īs intDirection = intDirection.None) As Pointĭim pntLoc As New Point(pntLocation.X, pntLocation.Y) Public Sub New(ByVal iStep As Integer, ByVal pStart As Point, _Įither one of these (depending on whether you have instantiated the class with parameters or without parameters) sets the default values of the direction, location, or growing objects. These properties determine the direction the snake is moving, where it is, and by how many segments it should grow after it has eaten. Public ReadOnly Property Increment() As Integer Public Property Direction() As intDirection Public ReadOnly Property Location() As Point Then, add the following Properties and Enum to clsMovement: Private pntLocation As Point Name the objects anything you desire, but keep in mind that my names may differ from yours.Īdd a new class to your project. This project needs a big Picturebox, one Label, and one Timer. Once your project has been created, design your form to resemble Figure 1:
#Classic snake arcade game windows#
Open Visual Studio and create a new Visual Basic Windows Forms project. Each item eaten makes the snake longer, causing the controlling of the snake’s movements to progressively become more difficult. Playing the game involves a player having to attempt to “eat” items by running into them with the head of the snake. Today, however, there are hundreds of variances of the original Snake game. The Snake concept originated in the arcade game Blockade in 1976.

Snake is simply a name for a video game concept where the player has to maneuver a line which grows in length. Contrary to popular belief, Nokia did not pioneer the Snake game, though. For example, you can get bonus points to travel on the Golden Gate Bridge, the Ferry Building and the Palace of Fine Arts in San Francisco.Because the old classic Nokia phones have made a comeback, I thought it apt to write about the most popular feature of the Nokia-phone–era: Snake. It makes it a bit harder to maneuver on the screen for each passenger you pick-up as it is getting bigger.Įvery city of Google’ version has a few landmarks, which give you extra points for moving over them. Your goal is to pick train passengers that is done by driving over passengers without hitting yourself on the side of the game board. The train is used as a substitute of snake which is controlled using your keyboard’s arrow keys. You can play the game on your desktop browser by visiting standalone site for Snake Game or find the Play Snake option in Google Maps Settings on your smartphone (refer to the GIF below if you have problems). You can play Snake on your desktop or on the smartphone app ‘Maps’ in some major cities worldwide such as Cairo, Sao Paulo, London, Sydney, San Francisco and Tokyo. From today through the end of the week this Easter egg will be available. Google Maps releases classic Snake arcade game to celebrate this year April Fool’s Day.
