![]() ![]() Snake. Void addCoordinateAtTheBack(Coordinate coordinate) else if (//direction is left and coordinateHeadSnake.x go to start positionĬoordinateHeadSnake = new Coordinate(0,1) You don’t have to create a method because you will not create anything, but just save the value of two variables.ĬoordinateArray = new Coordinate We only have to save the x and y coordinate. ![]() The class coordinate will be a very short class. We will now first create the class coordinate and snake. Now we know what we have to write in the main method. game over method => when the snake hits itself.set methods (for example: set apple, set snake start position, etc…).a loop method (when you don’t change the direction).Because the snake will consist more than one piece,Ĭoordinates will differ from each other and therefore it will be the same situation as in the example of the sheep. You have to save the snake object in the game in an array. Why three classes? As you can see on the page about classes. You have of course the main game, but you also have 2 other classes. You can find a nice tutorial over there, to start from nothing and build snake.Īlright, the first thing you have to do is to split the assignment into 3 parts. If you don’t have a game interface, go to. music v1. ![]() Most of the time when you get an assignment like this the school will provide a game interface. Geometry Calculator (BlueJ application) When this program is opened, it will now prompt the user to select the shape before entering the radius and height. If you are a beginning programmer, it is easier to use an already existing game interface. Let's do that next.In this game are you using all the things you have learned in the previous chapters.
0 Comments
Leave a Reply. |