Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Snake Game (Tutorial Edition)
#1
So I just spent about 3 hours recording a 6-part tutorial series demonstrating how to make the classic game "snake" in Java. Although I still have to edit each video, upload it, make the code package, etc, I would like to share the final ideas with you early!

The project consists of three main classes:
**Direction - holds enumerations relating to the    direction that the snake can travel
**snakeApplet - creates an applet that the canvas can run in
**snakeCanvas - a canvas object that calculates all the snake game's logic and draws the game.



So, when I previously made snake I had a difficulty figuring out how to make all of the body parts turn when they reached the point where the user pressed the arrow key. Well, I came to a realization when making this tutorial series. Instead of actually moving the various body parts across the grid, I could create a new head and delete the tail. This would resolve the issue of every body part actually having to turn and would allow for calculations to be much more efficient. Here's a visual of my new understanding:
   

Because of this, all calculations can now happen before any visualization is displayed. The tail is snipped and all calculations occur before the new head is placed.

Watch the tutorial series starting with number one, found here:
https://www.youtube.com/watch?v=FABTl1Q1...i&index=14


Get the working source code here (Covers until part 6):

.zip   SnakeTutorialSource.zip (Size: 2.22 KB / Downloads: 4,075)
My Blog | My Setup | My Videos | Have a wonderful day.


Messages In This Thread
Snake Game (Tutorial Edition) - by brandonio21_phpbb3_import2 - 06-23-2013, 10:20 PM
Snake game - by bedigursimran - 11-19-2013, 01:31 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)