06-23-2013, 10:20 PM
(This post was last modified: 04-14-2015, 09:21 PM by brandonio21.)
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):
SnakeTutorialSource.zip (Size: 2.22 KB / Downloads: 4,074)
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):
SnakeTutorialSource.zip (Size: 2.22 KB / Downloads: 4,074)