This site requires JavaScript, please enable it in your browser!
Greenfoot back
Jrm1715
Jrm1715 wrote ...

2012/10/14

Need someone to explain something to me.

Jrm1715 Jrm1715

2012/10/14

#
I have been tinkering around with some of the scenarios that come with the book. I am currently studying the source code to the scenario Breakout and I am understanding it fairly well for the exception of this part.
private void checkPaddle()
    {
        Actor paddle = getOneIntersectingObject(Paddle.class);
        if (paddle != null) {
            deltaY = -deltaY;
            int offset = getX() - paddle.getX();
            deltaX = deltaX + (offset/10);
            if (deltaX > 10) {
                deltaX = 10;
            }
            if (deltaX < -10) {
                deltaX = -10;
            }
        }            
    }
Focusing on the line "deltaX = deltaX + (offset/10);" what does the keyword "offset" mean and what does it do? I appreciate any explanation.
Game/maniac Game/maniac

2012/10/14

#
In this class offset = getX() - paddle.getX()
Jrm1715 Jrm1715

2012/10/14

#
Got it. I just didn't look closely enough XD
You need to login to post a reply.