I have been working on my Pong game and I added some nice new things to it. You can now select the difficulty on the start screen and I also added a pause screen. Also I gave the Pong ball a tail just like in Snake.The game is running fine on Windows but on Android, each 1/2 sec, I'm getting small FPS drops. I was wondering if there are any tips on making the game performance better so it needs less RAM/CPU space to run smooth.Also tips how to make my code easier to read and more clean would be nice.This is how my game looks like at the moment:Here are my working classes for this game right now:MainScreen.javapackage ***.***.***;import com.badlogic.gdx.Gdx;import com.badlogic.gdx.Screen;import com.badlogic.gdx.graphics.GL20;import com.badlogic.gdx.graphics.Texture;import com.badlogic.gdx.graphics.g2d.BitmapFont;import com.badlogic.gdx.graphics.g2d.SpriteBatch;import ***.***.***.Paddle;import ***.***.***.Ball;import com.badlogic.gdx.graphics.glutils.ShapeRenderer;import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;import ***.***.***.Tail;public class MainScreen implements Screen {    private GameState gameState = GameState.MENU;    private GameType gameType = GameType.EASY;    int countdown = 90;    int ballt=20;    int i = 0;;    float EnemySpeed;    float BallSpeed;    float DragX;    float TouchX;    float PlayerX;    float distance;    boolean tap = true;;    boolean col; //Colission check    boolean tapped = true;    private int score = 0;    private int lives = 5;    private Paddle player;    private Paddle enemy;    private Ball ball;    private BitmapFont font;    private SpriteBatch batch;    private ShapeRenderer shape;    Tail[] tail = new Tail[10];    Texture BackGround;    Texture PauseIcon;    public static float difficulty;    float width = Gdx.graphics.getWidth();    float height = Gdx.graphics.getHeight();    float screenwidth = width / 270;    float screenheight = height / 480;    public MainScreen() {        player = new Paddle();        enemy  = new Paddle();        ball = new Ball();        for(int i = 0; i < tail.length; i++){            tail[i] = new Tail(0,0);        }        batch = new SpriteBatch();        shape = new ShapeRenderer();        //Load in Fonts        font = new BitmapFont(Gdx.files.internal(data/whitetext.fnt),        Gdx.files.internal(data/whitetext.png), false);        BackGround = new Texture(data/background.jpg);        PauseIcon = new Texture(data/pause_icon.png);    }    public enum GameState {        MENU, INIT, START, UPDATE, GAMEOVER, PAUSE, EXIT, WIN;    }    public enum GameType {        EASY, NORMAL, HARD;    }    @Override    public void render(float delta) {        if (gameState != GameState.PAUSE){        Update();        }else{            pause();        }        if(Gdx.input.isTouched()){tap = false;}else tap = true;    }    private boolean hasBallCollision(Paddle player2){        if(ball.getX()+8*screenwidth>player2.getX()-40*screenwidth&&ball.getX()+8*screenwidth<player2.getX()+40*screenwidth){            if(ball.getY()>player2.getY()&&ball.getY()<player2.getY()+16*screenheight){                col = true;                return true;            }            return false;        }else{            return false;        }    }    public float getDif() {        return difficulty;    }    public void setDif(float difficulty) {        this.difficulty = difficulty;    }    public void Update(){        //DRAW BACKGROUND        batch.begin();        batch.draw(BackGround,0,0,270*screenwidth,480*screenheight);        batch.end();        //Player Drag        if(Gdx.input.isTouched() && Gdx.input.getY()>240*screenheight){            DragX = Gdx.input.getX();            if(tapped)distance = DragX - player.getX();            tapped = false;            PlayerX = DragX+-distance;        }else{            tapped = true;        }        //MENU        if(gameState == GameState.MENU){            if (Gdx.input.isTouched() && tap && Gdx.input.getY()>230*screenheight && Gdx.input.getY()<260*screenheight && Gdx.input.getX()>95*screenwidth && Gdx.input.getX()<175*screenwidth){gameType = GameType.EASY;gameState = GameState.INIT;}            if (Gdx.input.isTouched() && tap && Gdx.input.getY()>280*screenheight && Gdx.input.getY()<310*screenheight && Gdx.input.getX()>75*screenwidth && Gdx.input.getX()<205*screenwidth){gameType = GameType.NORMAL;gameState = GameState.INIT;}            if (Gdx.input.isTouched() && tap && Gdx.input.getY()>330*screenheight && Gdx.input.getY()<360*screenheight && Gdx.input.getX()>95*screenwidth && Gdx.input.getX()<175*screenwidth){gameType = GameType.HARD;gameState = GameState.INIT;}            //Gdx.app.log(X+Gdx.input.getX(), Y+Gdx.input.getY());            batch.begin();            font.setColor(1.0f, 1.0f, 1.0f, 1.0f);            font.setScale(1.0f*screenwidth,1.0f*screenheight);            font.draw(batch, PONG, 60*screenwidth, 400*screenheight);            font.setScale(0.5f*screenwidth,0.5f*screenheight);            font.draw(batch, EASY, 95*screenwidth, 250*screenheight);            font.draw(batch, NORMAL, 75*screenwidth, 200*screenheight);            font.draw(batch, HARD, 95*screenwidth, 150*screenheight);            batch.end();        }        //INIT        if(gameState == GameState.INIT){            player.init(40);            enemy.init(430);            ball.init();            gameState = GameState.START;            difficulty = 1.0f;            countdown = 90;        }        //START        if(gameState == GameState.START){            if(countdown == 0) gameState = GameState.UPDATE;            countdown--;            batch.begin();            font.setColor(1.0f, 1.0f, 1.0f, 1.0f);            font.setScale(1.0f*screenwidth,1.0f*screenheight);            if(countdown >= 60 && countdown <= 90)font.draw(batch, 3, 120 * screenwidth, 300 * screenheight);            if(countdown >= 30 && countdown <= 60)font.draw(batch, 2, 120 * screenwidth, 300 * screenheight);            if(countdown >= 0 && countdown <= 30)font.draw(batch, 1, 120 * screenwidth, 300 * screenheight);            batch.end();        }        //UPDATE        if(gameState == GameState.UPDATE){        if (Gdx.input.isTouched() && tap && Gdx.input.getY()>0 && Gdx.input.getY()<32*screenheight && Gdx.input.getX()>0 && Gdx.input.getX()<32*screenwidth) gameState= GameState.PAUSE;        player.setX(PlayerX);        player.update();        enemy.update();        for (int i = tail.length - 1; i > 0; i--) {             tail[i] = tail[i - 1];            tail[i].Update();        }        tail[0] = new Tail(ball.getX(),ball.getY());        ball.update();        //DRAW SCORE/LIVES/PAUSEICON        batch.begin();        font.setColor(1.0f, 1.0f, 1.0f, 1.0f);        font.setScale(0.2f*screenwidth,0.2f*screenheight);        font.draw(batch, Score: + score +/5, 190 * screenwidth, 475 * screenheight);        font.draw(batch, Lives: + lives, 45 * screenwidth, 475 * screenheight);        batch.draw(PauseIcon,0,448*screenheight,32.0f*screenwidth,32.0f*screenheight);        batch.end();        }        if(lives == 0)gameState = GameState.GAMEOVER;        if(score == 5)gameState = GameState.WIN;        if(ball.getY() < 0 * screenheight){            lives--;            gameState = GameState.INIT;        }        if(ball.getY() > 480 * screenwidth - 16 * screenwidth){            score++;            gameState = GameState.INIT;        }        //LOSE SCREEN        if(gameState == GameState.GAMEOVER){            if(tap && Gdx.input.isTouched())gameState=GameState.MENU;            batch.begin();            font.setColor(1.0f, 1.0f, 1.0f, 1.0f);            font.setScale(0.5f * screenwidth,0.5f * screenheight);            font.draw(batch, Game Over, 30 * screenwidth, 300 * screenheight);            font.setScale(0.3f * screenwidth,0.3f * screenheight);            font.draw(batch, Main Menu, 60 * screenwidth, 260 * screenheight);            batch.end();            score = 0;            lives = 5;        }        //WIN SCREEN        if(gameState == GameState.WIN){            if(tap && Gdx.input.isTouched())gameState=GameState.MENU;            Gdx.app.log(TAP+tap, Touched+Gdx.input.isTouched());            batch.begin();            font.setColor(1.0f, 1.0f, 1.0f, 1.0f);            font.setScale(0.5f * screenwidth,0.5f * screenheight);            font.draw(batch, You Won!, 60 * screenwidth, 300 * screenheight);            font.setScale(0.4f*screenwidth,0.4f * screenheight);            font.draw(batch, Main Menu, 20 * screenwidth, 260 * screenheight);            batch.end();            score = 0;            lives = 5;        }        //Difficulty        if(gameType == GameType.EASY){EnemySpeed=2.2f;BallSpeed=0.1f;}        if(gameType == GameType.NORMAL){EnemySpeed=2.5f;BallSpeed=0.2f;}        if(gameType == GameType.HARD){EnemySpeed=3.0f;BallSpeed=0.5f;}        //Enemy Ball Colission        if(ball.getX() + 8 * screenwidth > enemy.getX() - 40 * screenwidth && ball.getX() + 8 * screenwidth<enemy.getX() + 40 * screenwidth){            if(ball.getY() + 16 * screenheight > enemy.getY() && ball.getY() + 16 * screenheight<enemy.getY() + 16 * screenheight){                float zy;                zy = -3 * screenheight;                ball.setZy(zy);                if(col)difficulty += BallSpeed;                col = false;            }        }        //Enemy AI        if(enemy.getX()<ball.getX()){            float ex;            ex = EnemySpeed * screenwidth * difficulty;            enemy.setDeltaX(ex);        }        if(enemy.getX() > ball.getX()){            float ex;            ex = - EnemySpeed * screenwidth * difficulty;            enemy.setDeltaX(ex);        }        //Gdx.app.log(TAP, +tap);        if (hasBallCollision(player)){            ball.setZy(3 * screenheight);        }    }    @Override    public void resize(int width, int height) {    }    @Override    public void show() {        Gdx.app.log(Show, Called);    }    @Override    public void hide() {        Gdx.app.log(Hide, Called);    }    @Override    public void pause() {            if(tap && Gdx.input.isTouched() && Gdx.input.getY()<240*screenheight)gameState=GameState.UPDATE;        if(tap && Gdx.input.isTouched() && Gdx.input.getY()>240*screenheight){gameState=GameState.MENU;score=0; lives=5;}        batch.begin();        batch.draw(BackGround,0,0,270*screenwidth,480*screenheight);        font.setColor(1.0f, 1.0f, 1.0f, 1.0f);        font.setScale(0.4f*screenwidth,0.4f * screenheight);        font.draw(batch, Tap to Resume, 25 * screenwidth, 360 * screenheight);        font.draw(batch, Main Menu, 60 * screenwidth, 160 * screenheight);        batch.end();    }    @Override    public void resume() {        Gdx.app.log(Resume, Called);    }    @Override    public void dispose() {    }}Paddle.java //enemy and player barpackage ***.***.***;import com.badlogic.gdx.Gdx;import com.badlogic.gdx.graphics.Texture;import com.badlogic.gdx.graphics.g2d.SpriteBatch;public class Paddle {    private float width = Gdx.graphics.getWidth();    private float height = Gdx.graphics.getHeight();    private float screenwidth = width/270;    private float screenheight = height/480;    private SpriteBatch batch;    private Texture sprite;    private float x,y;    private float deltaX;    public void init(int parameter) {        x=135*screenwidth;        y=parameter*screenheight;        batch = new SpriteBatch();        sprite = new Texture(data/bar.png);    }    public void setX(float ex) {         x = ex;    }    public void setY(float ex) {         y = ex;    }    public void update(){        x += deltaX;        if(x>229*screenwidth)x=229*screenwidth;        if(x<41*screenwidth)x=41*screenwidth;        batch.begin();        batch.draw(sprite,x-40*screenwidth,y,80*screenwidth,16*screenheight);        batch.end();    }    public float getX() {        return x;    }    public float getY(){        return y;    }    public void setDeltaX(float deltaX) {        this.deltaX = deltaX;    }}Ball.javapackage ***.***.***;import java.util.Random;import com.badlogic.gdx.Gdx;import com.badlogic.gdx.graphics.Texture;import com.badlogic.gdx.graphics.g2d.SpriteBatch;import ***.***.***.MainScreen;public class Ball {    SpriteBatch batch;    Texture ballsprite;    Random random = new Random();    float width = Gdx.graphics.getWidth();    float height = Gdx.graphics.getHeight();    float screenwidth = width/270;    float screenheight = height/480;    public float x,y,zx,zy,randomx,randomw;    float difficulty;    private MainScreen main;    public Ball(){    }    public void init(){        batch = new SpriteBatch();        ballsprite = new Texture(data/ball.png);        x = 127 * screenwidth;        y = 232 * screenheight;        randomw = random.nextInt(2);        if(randomw == 1)randomw =- 1;else randomw = 1;        randomx = random.nextInt(20) + 20;        zx = randomx / 10 * screenwidth * randomw;        zy = 3 * screenwidth;        main = new MainScreen();    }    public void update(){        difficulty = main.getDif();        //Colission check        if(x<0*screenheight)zx = 3 * screenwidth;        if(x>270*screenwidth - 16 * screenwidth)zx =- 3 * screenwidth;        x += zx * difficulty;        y += zy * difficulty;        //Draw ball        batch.begin();        batch.draw(ballsprite,x,y,16 * screenheight,16 * screenwidth);        batch.end();    }    public float getX() {        return x;    }    public float getY() {        return y;    }    public void setZy(float zy) {        this.zy = zy;    }    public void setZx(float zx) {        this.zx = zx;    }}Tail.java // The new class for the tail following the ball.package ***.***.***;import com.badlogic.gdx.Gdx;import com.badlogic.gdx.graphics.Color;import com.badlogic.gdx.graphics.g2d.SpriteBatch;import com.badlogic.gdx.graphics.glutils.ShapeRenderer;import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;public class Tail {    float width = Gdx.graphics.getWidth();    float height = Gdx.graphics.getHeight();    float screenwidth = width/270;    float screenheight = height/480;    public float x;    public float y;    ShapeRenderer shapeRenderer;    SpriteBatch batch;    public boolean active = false;    public Tail(float x, float y){        shapeRenderer = new ShapeRenderer();        batch = new SpriteBatch();        this.x = x;        this.y = y;    }    public void Update(){          batch.begin();          shapeRenderer.begin(ShapeType.Filled);          shapeRenderer.setColor(new Color(1, 1, 1, 0.2f));          shapeRenderer.circle(x+8*screenwidth, y+8*screenheight, 6*screenheight);          shapeRenderer.end();          batch.end();      }}
Simple LibGDX Pong game 2.0
java;game;libgdx