Monday, August 26, 2013
Snakes Everywhere!
This is a game of snake that I wrote for Software Development 2. It uses standard draw package from Java and has a basic splash screen. I do realize that there is a better way to draw the snake and update the screen but the assignment told us to use StdDraw. There are a few bugs, such as I cannot get it to register the keys Y or N when I would like to restart the game. After this semester with Advanced Java I think I will be able to make a better version. I may even try my had at a side scrolling shooter.
To download files go to: https://github.com/zmchenry/Snake
The Snake.java is the main file. If you would like to run this yourself you will need the StdDraw.java file found here: StdDraw.java This is the apple file that controls all of the attributes of the apple, such as the amount of time the apple will stay in a position. I am only going to post the collision detection in from my Snake game here but the rest of the project can be found on my GitHub. The collision detection works by looking at the position of the head and comparing it to the walls, the rest of the body, and the apples. To keep position I used an 2 arrays to keep the x and y positions of the body and then the apples have their own getter methods for getting their x and y position. To check the walls, I compared the position of the head to the amount of pixels that the wall would take up. I do not own the rights to StdDraw and I did not create StdDraw that was created by Sedgewick for his Algorithms book and his Introduction to Java Fundamentals book.
Labels:
Computer Science
,
Florida Institute of Technolgy
,
Florida Tech
,
Java Game
,
Snake
,
Snake.java
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment