Advertisement
sergeyiandronov

Untitled

Jan 28th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. package com.example.student3.game1;
  2.  
  3. import java.util.Random;
  4.  
  5. /**
  6. * Created by student3 on 28.01.17.
  7. */
  8.  
  9. public class Star {
  10.  
  11. private int x;
  12. private int y;
  13. private int speed;
  14.  
  15.  
  16. private int maxX;
  17.  
  18. private int minX;private int maxY;private int minY;
  19.  
  20. public int getMinY() {
  21. return minY;
  22. }
  23.  
  24. public void setMinY(int minY) {
  25. this.minY = minY;
  26. }
  27.  
  28. public int getMaxY() {
  29. return maxY;
  30. }
  31.  
  32. public void setMaxY(int maxY) {
  33. this.maxY = maxY;
  34. }
  35.  
  36. public int getMinX() {
  37. return minX;
  38. }
  39.  
  40. public void setMinX(int minX) {
  41. this.minX = minX;
  42. }
  43.  
  44. public int getMaxX() {
  45. return maxX;
  46. }
  47.  
  48. public void setMaxX(int maxX) {
  49. this.maxX = maxX;
  50. }
  51.  
  52. public int getSpeed() {
  53. return speed;
  54. }
  55.  
  56. public void setSpeed(int speed) {
  57. this.speed = speed;
  58. }
  59.  
  60. public int getY() {
  61. return y;
  62. }
  63.  
  64. public void setY(int y) {
  65. this.y = y;
  66. }
  67.  
  68. public int getX() {
  69. return x;
  70. }
  71.  
  72. public void setX(int x) {
  73. this.x = x;
  74. }
  75.  
  76. public Star(int screenX, int screenY){
  77. maxY=screenY;
  78. maxX=screenX;
  79. minX=0;
  80. minY=0;
  81. Random generator=new Random();
  82. speed=generator.nextInt(10);
  83. x=generator.nextInt(maxX);
  84. y=generator.nextInt(maxY);
  85.  
  86. }
  87. public void update(int playerSpeed){
  88. x-=playerSpeed;
  89. x-=speed;
  90. if(x<0){
  91. x=maxX;
  92. Random generator= new Random();
  93. y=generator.nextInt(maxY);
  94. x=generator.nextInt(15);
  95.  
  96. }
  97. }
  98.  
  99.  
  100.  
  101. public float getStarWidth(){
  102. float minX=1.0f;
  103. float minY=4.0f;
  104. Random rand=new Random();
  105. float finalX=rand.nextFloat()*(maxX-minX)+minX;
  106. return finalX;
  107.  
  108. }
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement