Advertisement
Guest User

Untitled

a guest
Nov 14th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.46 KB | None | 0 0
  1. package com.company;
  2.  
  3. import com.badlogic.gdx.ApplicationListener;
  4. import com.badlogic.gdx.Gdx;
  5. import com.badlogic.gdx.Input;
  6. import com.badlogic.gdx.graphics.GL20;
  7. import com.badlogic.gdx.graphics.Texture;
  8. import com.badlogic.gdx.graphics.g2d.BitmapFont;
  9. import com.badlogic.gdx.graphics.g2d.Sprite;
  10. import com.badlogic.gdx.graphics.g2d.SpriteBatch;
  11.  
  12. public class AAA_AVOIDOBJECTGAME implements ApplicationListener {
  13.  
  14. int SCORE = 0;
  15. long TIME;
  16. SpriteBatch batch;
  17. Sprite Background;
  18. Sprite GO;
  19. Sprite MS;
  20. Sprite TF1;
  21. Sprite TF2;
  22. Sprite TF3;
  23. Sprite TF4;
  24. Sprite PS;
  25. Sprite S;
  26. Sprite OBJ;
  27.  
  28. BitmapFont font;
  29. @Override
  30. public void create() {
  31. batch = new SpriteBatch();
  32. Background = new Sprite(new Texture("ASSETS/TOB.jpg"));
  33. GO = new Sprite(new Texture("ASSETS/GO.jpg"));
  34. GO.setPosition(2000,2000);
  35. font = new BitmapFont();
  36. MS = new Sprite(new Texture("ASSETS/MS.png"));
  37. MS.setPosition(50, 50);
  38. TF1 = new Sprite(new Texture("ASSETS/TF.png"));
  39. TF1.setPosition(376,900);
  40. TF2 = new Sprite(new Texture("ASSETS/TF.png"));
  41. TF2.setPosition(702,900);
  42. TF3 = new Sprite(new Texture("ASSETS/TF.png"));
  43. TF3.setPosition(1028,900);
  44. TF4 = new Sprite(new Texture("ASSETS/TF.png"));
  45. TF4.setPosition(1354,900);
  46. PS = new Sprite(new Texture("ASSETS/PS.png"));
  47. PS.setPosition(1670, 50);
  48. S = new Sprite(new Texture("ASSETS/SCOREBOARD.png"));
  49. S.setPosition(50, 900);
  50. TIME = System.currentTimeMillis();
  51. OBJ = new Sprite(new Texture("ASSETS/OBJ.png"));
  52. OBJ.setPosition(50,785);
  53. }
  54.  
  55.  
  56. @Override
  57. public void render() {
  58. Gdx.gl.glClearColor(0,0,0,1);
  59. Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
  60. if(Gdx.input.isKeyPressed(Input.Keys.LEFT)) {
  61. MS.translateX(-5);
  62. }
  63. if(Gdx.input.isKeyPressed(Input.Keys.RIGHT)) {
  64. MS.translateX(5);
  65. }
  66. if(MS.getX() > 1870 - MS.getWidth()) {
  67. MS.setX(1870 - MS.getWidth());
  68. }
  69. if(MS.getX() < -50 + MS.getWidth()) {
  70. MS.setX(-50 + MS.getWidth());
  71. }
  72. TF1.translateY(-7);
  73. if(TF1.getY() < -125) {
  74. TF1.setY(1080);
  75. }
  76. TF2.translateY(-5);
  77. if(TF2.getY() < -125) {
  78. TF2.setY(1080);
  79. }
  80. TF3.translateY(-10);
  81. if(TF3.getY() < -125) {
  82. TF3.setY(1080);
  83. }
  84. TF4.translateY(-8);
  85. if(TF4.getY() < -125) {
  86. TF4.setY(1080);
  87. }
  88. if(MS.getBoundingRectangle().overlaps(TF1.getBoundingRectangle())) {
  89. MS.setPosition(50, 50);
  90. }
  91. if(MS.getBoundingRectangle().overlaps(TF2.getBoundingRectangle())) {
  92. MS.setPosition(50, 50);
  93. }
  94. if(MS.getBoundingRectangle().overlaps(TF3.getBoundingRectangle())) {
  95. MS.setPosition(50, 50);
  96. }
  97. if(MS.getBoundingRectangle().overlaps(TF4.getBoundingRectangle())) {
  98. MS.setPosition(50, 50);
  99. }
  100. if(MS.getBoundingRectangle().overlaps(PS.getBoundingRectangle())) {
  101. MS.setPosition(50, 50);
  102. SCORE++;
  103. }
  104. if(((System.currentTimeMillis() - TIME)/1000)>30){
  105. MS.setPosition(50, 2000);
  106. TF1.translateY(7);
  107. TF1.setY(2000);
  108. TF2.translateY(5);
  109. TF2.setY(2000);
  110. TF3.translateY(10);
  111. TF3.setY(2000);
  112. TF4.translateY(8);
  113. TF4.setY(2000);
  114. S.setY(2000);
  115. OBJ.setY(2000);
  116. PS.setY(2000);
  117. GO.setPosition(0,0);
  118. }
  119. batch.begin();
  120. Background.draw(batch);
  121. MS.draw(batch);
  122. TF1.draw(batch);
  123. TF2.draw(batch);
  124. TF3.draw(batch);
  125. TF4.draw(batch);
  126. PS.draw(batch);
  127. S.draw(batch);
  128. font.draw(batch, " " + (System.currentTimeMillis() - TIME)/1000, 247, 978);
  129. OBJ.draw(batch);
  130. GO.draw(batch);
  131. font.draw(batch, SCORE + " ", 250, 935);
  132. batch.end();
  133. }
  134.  
  135.  
  136. @Override
  137. public void resize(int i, int i1) {
  138.  
  139.  
  140. } @Override
  141. public void pause() {
  142.  
  143. }
  144.  
  145. @Override
  146. public void resume() {
  147.  
  148. }
  149.  
  150. @Override
  151. public void dispose() {
  152.  
  153. }
  154. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement