Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package ninja.mario;
- import java.awt.Graphics;
- import java.awt.Rectangle;
- /**
- *
- * @author brandontran
- */
- public class Ninja extends Token {
- int speed = 0;
- int maxSpeed;
- public Ninja(){
- super();
- maxSpeed = 20;
- }
- public Ninja(int x, int y, int height, int width, int maxSpeed){
- super(x,y,height,width);
- this.maxSpeed = maxSpeed;
- }
- public void setSpeed(int speed){
- this.speed = speed;
- }
- public int getSpeed(){
- return speed;
- }
- public int getMaxSpeed(){
- return maxSpeed;
- }
- public void paint(Ninja n,Graphics g){
- g.fillRect(n.getX(), n.getY(), n.getWidth(), n.getHeight());
- n.setX(n.getX() + speed);
- }
- public void jump(){
- }
- public void updatePos(Ninja n, int keyCode){
- //n.setSpeed(n.maxSpeed);
- //n.setX(n.getX() + n.getSpeed());
- //if(direction == 87 || direction == 32){ } //w or space
- System.out.println(keyCode);
- if(keyCode == 65){ //a
- x -= 20; //move left
- }
- else if(keyCode == 68){ //d
- x += 20; //move right
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement