Advertisement
Guest User

Untitled

a guest
May 28th, 2015
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1.  
  2. private GameLoopMethod()
  3. {
  4.     // Doing derp stuff
  5.     Coordinates newCoords = followPotatoes(x, y, a, b);
  6.    
  7.     myObjectThatNeedsToFollowStuff.x = newCoords.xCoord;
  8.     myObjectThatNeedsToFollowStuff.y = newCoords.yCoord;
  9. }
  10.  
  11. private Coordinates followPotatoes(int x, int y, int a, int b)
  12. {
  13.     if (a != x) {
  14.         if (a < x) {
  15.             a += 1;
  16.         } else {
  17.             a -= 1;
  18.         }
  19.     }
  20.  
  21.     if (b != y) {
  22.         if (b < y) {
  23.             b += 1;
  24.         } else {
  25.             b -= 1;
  26.         }
  27.     }
  28.     Coordinates returnCoords = new Coordinates(a, b);
  29.     return returnCoords;
  30. }
  31.  
  32. ===
  33. DIFFERENT FILE
  34. ===
  35.  
  36. public class Coordinates
  37. {
  38.     public int xCoord;
  39.     public int yCoord;
  40.  
  41.     public Coordinates(int x, int y) {
  42.         xCoord = x;
  43.         yCoord = y;
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement