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: 2,051)
My Blog | My Setup | My Videos | Have a wonderful day.
#2
Hi Guys.

I got the snake Game working great and I made a few changes to it too. And I was wondering if there is any way that I can save this as a 'Runnable Jar' file, so I can give it to my friend and try it without having Eclipse. Because it always give me an error like "couldn't find the main". I looked in the code provided by BrandonioProductions as well, and there wasn't any 'public static void main(String[] args)'.

Thanks,
Any help would be appreciated.


Forum Jump:


Users browsing this thread: 1 Guest(s)