Advertisement
Guest User

Untitled

a guest
May 6th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package ninja.mario;
  7.  
  8. import java.awt.Graphics;
  9. import java.awt.Rectangle;
  10.  
  11. /**
  12. *
  13. * @author brandontran
  14. */
  15. public class Ninja extends Token {
  16. int speed = 0;
  17. int maxSpeed;
  18. public Ninja(){
  19. super();
  20. maxSpeed = 20;
  21. }
  22. public Ninja(int x, int y, int height, int width, int maxSpeed){
  23. super(x,y,height,width);
  24. this.maxSpeed = maxSpeed;
  25. }
  26. public void setSpeed(int speed){
  27. this.speed = speed;
  28. }
  29. public int getSpeed(){
  30. return speed;
  31. }
  32. public int getMaxSpeed(){
  33. return maxSpeed;
  34. }
  35. public void paint(Ninja n,Graphics g){
  36. g.fillRect(n.getX(), n.getY(), n.getWidth(), n.getHeight());
  37. n.setX(n.getX() + speed);
  38. }
  39. public void jump(){
  40.  
  41. }
  42. public void updatePos(Ninja n, int keyCode){
  43. //n.setSpeed(n.maxSpeed);
  44. //n.setX(n.getX() + n.getSpeed());
  45. //if(direction == 87 || direction == 32){ } //w or space
  46. System.out.println(keyCode);
  47. if(keyCode == 65){ //a
  48. x -= 20; //move left
  49. }
  50. else if(keyCode == 68){ //d
  51. x += 20; //move right
  52. }
  53.  
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement