Advertisement
Guest User

Untitled

a guest
Dec 30th, 2014
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. public class Game extends ApplicationAdapter {
  2. SpriteBatch batch;
  3. Texture img;
  4. int[] numbers;
  5. float ticker=0;
  6. int indexer=0;
  7. BitmapFont font;
  8. public void create () {
  9.  
  10. //All of this bit is just setting up stuff in LibGDX for rendering and making a 1x1 white texture//
  11. batch = new SpriteBatch();
  12. font = new BitmapFont();
  13. int size=1;
  14. Pixmap map = new Pixmap(size, size, Format.RGBA8888);
  15. map.setColor(1,1,1,1);
  16. map.fillRectangle(0, 0, size, size);
  17. img=new Texture(map);
  18. //
  19.  
  20. //Setting up array of random integers//
  21. int aSize=500000;
  22. numbers= new int[aSize];
  23. for(int i=0;i<aSize;i++){
  24. numbers[i]=(int) (Math.random()*Gdx.graphics.getHeight());
  25. }
  26. }
  27.  
  28. public void update(float delta){
  29. float speed=180;
  30. ticker+=delta*speed;
  31. while(ticker>1){
  32. ticker-=1;
  33. indexer++;
  34. }
  35. }
  36.  
  37. //Render gets called by LibGDX and I call update from the render function//
  38. public void render () {
  39. update(Gdx.graphics.getDeltaTime());
  40. Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
  41. batch.begin();
  42. int scale=3;
  43. for(int x=0;x<Gdx.graphics.getWidth();x+=scale){
  44. batch.draw(img, x, 0, scale, numbers[(int) (x/scale+indexer)]);
  45. }
  46. batch.end();
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement