Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Game extends ApplicationAdapter {
- SpriteBatch batch;
- Texture img;
- int[] numbers;
- float ticker=0;
- int indexer=0;
- BitmapFont font;
- public void create () {
- //All of this bit is just setting up stuff in LibGDX for rendering and making a 1x1 white texture//
- batch = new SpriteBatch();
- font = new BitmapFont();
- int size=1;
- Pixmap map = new Pixmap(size, size, Format.RGBA8888);
- map.setColor(1,1,1,1);
- map.fillRectangle(0, 0, size, size);
- img=new Texture(map);
- //
- //Setting up array of random integers//
- int aSize=500000;
- numbers= new int[aSize];
- for(int i=0;i<aSize;i++){
- numbers[i]=(int) (Math.random()*Gdx.graphics.getHeight());
- }
- }
- public void update(float delta){
- float speed=180;
- ticker+=delta*speed;
- while(ticker>1){
- ticker-=1;
- indexer++;
- }
- }
- //Render gets called by LibGDX and I call update from the render function//
- public void render () {
- update(Gdx.graphics.getDeltaTime());
- Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
- batch.begin();
- int scale=3;
- for(int x=0;x<Gdx.graphics.getWidth();x+=scale){
- batch.draw(img, x, 0, scale, numbers[(int) (x/scale+indexer)]);
- }
- batch.end();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement