Wednesday, 4 December 2013

#FLMobiGame - Functions

On Week 6 we are discussing functions in #FLMobiGame. The function we are using in the game is quite lengthy so I thought I would show a small function in a java file to show where they are positioned. I will use blank functions to make the code shorter.

Line1: public class TheGame extends GameThread{
Line 2:          //Here all variables used in the game with 'm' prefix will be defined
Line 3:         //from here onward the functions will be defined
Line 4:         public TheGame(GameView gameView) {
Line 5:         }
Line 6:        public void setupBeginning() {
Line 7:        }
Line 8:       //there will be lot more code in between
Line 9:      //Collusion control between mBall and another big ball
Line 10:    private boolean updateBallCollusion(float x, float y) {
Line 11:       return true; //we are not doing anything but returning true here
Line 12: }
Line 13:}//this is the End curly bracket from Line 1

This Java tutorial explains returning values from methods. In #FLMobiGame we were looking at basics of programming, so we did not talk about Object Oriented Concepts. If you are interested in knowing more about Object Orientation you can have a look at these tutorials: OOConcepts; Classes and Objects

No comments:

Post a Comment