1. Download our Official Android App: Forums for Android!

Apps Understanding graphic editing...

Discussion in 'Android Development' started by jon80, Jan 3, 2015.

  1. jon80

    jon80 On Probation
    Thread Starter
    Rank:
    None
    Points:
    16
    Posts:
    58
    Joined:
    Nov 5, 2013

    Nov 5, 2013
    58
    3
    16
    Male
    Software Engineer
    Malta, Europe
    Is this an algorithm that is backed by geometry theory, and, which if I may ask?

    privatevoid update() {

    if (x > gameView.getWidth() - width - xSpeed) {

    xSpeed = -5;

    }

    if (x + xSpeed < 0) {

    xSpeed = 5;

    }

    x = x + xSpeed;

    currentFrame = ++currentFrame % BMP_COLUMNS;
    http://www.edu4java.com/en/androidgame/androidgame4.html
     

    Advertisement

  2. Manaya

    Manaya Member
    Rank:
    None
    Points:
    18
    Posts:
    62
    Joined:
    Aug 4, 2014

    Aug 4, 2014
    62
    14
    18
    update is probably called every frame to update the scene, although it's pretty flawed because it doesn't use a deltaTime system.

    The first if makes sure that the sprite doesn't pass over the right border of the screen. Instead, it makes it go the opposite way when it reaches that point.

    The second if is the same, but for the left border of the screen.

    x += xSpeed is just updating the position of the sprite every frame

    And the last line is updating the animation of the sprite by going a different bitmap frame every game frame. The modulus operator makes sure the animation just loops back to start when it goes over the last animation frame
     
    jon80 likes this.
  3. jon80

    jon80 On Probation
    Thread Starter
    Rank:
    None
    Points:
    16
    Posts:
    58
    Joined:
    Nov 5, 2013

    Nov 5, 2013
    58
    3
    16
    Male
    Software Engineer
    Malta, Europe

Share This Page

Loading...