Advertisement
Guest User

Player.java

a guest
Nov 26th, 2012
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.51 KB | None | 0 0
  1. package game;
  2.  
  3. public class Player
  4. {
  5.     private Sprite sprite;
  6.     private boolean left,right;
  7.    
  8.     public Player(float x, float y)
  9.     {
  10.         sprite = new Sprite("player.png",x,y);
  11.     }
  12.     public void draw()
  13.     {
  14.         sprite.draw();
  15.     }
  16.     public void move()
  17.     {
  18.         if(left)
  19.         {
  20.             sprite.setX(sprite.getX() - (float)0.2*CL2.delta);
  21.         }
  22.         if(right)
  23.         {
  24.             sprite.setX(sprite.getX() + (float)0.2*CL2.delta);
  25.         }
  26.     }
  27.     public void left(boolean b)
  28.     {
  29.         left = b;
  30.     }
  31.     public void right(boolean b)
  32.     {
  33.         right = b;
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement