![]() To play snake, you’ll need to select animated passengers as humans once the train is moving. The direction of the snake’s movement is controlled by the arrow keys on the top, bottom, left, and right of your keyboard, just like in the original snake (user input keys). The game displays the player’s score at the end of each round. Start the game and play snake as soon as you have a location. You can select from a list of 8-bit-style locations, such as Sao Paulo, San Francisco, Cairo, London, Tokyo, and World, to which you can travel.ĭepending on where you’re going, the design of each train varies. To begin this Google Snake game, you must select a subway train from the list. Next, you’ll need to press the appropriate button. You’ll see a big “Start” button and a few 8-bit characters across a map when you arrive at the Google Maps Snake game’s home page. If you have an iOS or Android mobile device, you can use this link. Go to (or type “play Snake” into Google Search) to begin the game. After all, logic is what it is all about.To play snake, you must have a web browser and a smartphone. I hope that you would agree that creating a snake game was quite fun. The code for this article is available on GitHub. ) Handles MyBase.KeyDownĬMovement.Direction = ĬMovement.Direction = ĬMovement.Direction = ĬMovement.Direction = Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As _ ) Handles MyBase.KeyUpĭisplayMessage("Press Enter to continue or Escape _ Private Sub Form1_KeyUp(ByVal sender As Object, ByVal e As _ Private Sub tmrGame_Tick(ByVal sender As System.Object, _īyVal e As System.EventArgs) Handles tmrGame.Tick ) Handles picGame.PaintĮ.Graphics.FillEllipse(Brushes.White, rectFood)įor Each segCurrent In cSnake.NumberOfSegmentsĮ.Graphics.FillRectangle(Brushes.White, segCurrent.Rect) Private Sub picGame_Paint(ByVal sender As Object, ByVal e As _ 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: 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. 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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |