Snake Game (Tutorial Edition) - Printable Version +- BP Forums (https://bpforums.info) +-- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=55) +--- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=56) +---- Forum: Java (https://bpforums.info/forumdisplay.php?fid=19) +----- Forum: Code Snippets (https://bpforums.info/forumdisplay.php?fid=32) +----- Thread: Snake Game (Tutorial Edition) (/showthread.php?tid=794) |
Snake Game (Tutorial Edition) - brandonio21 - 06-23-2013 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=FABTl1Q1byw&list=PL13bz4SHGmRzIHoVh-B30U7jttLxYN_yi&index=14 Get the working source code here (Covers until part 6): SnakeTutorialSource.zip (Size: 2.22 KB / Downloads: 4,075) Snake game - bedigursimran - 11-19-2013 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. |