Skip to content
Permalink
8ba4e500aa
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
65 lines (53 sloc) 1 KB
package main;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
public class Player {
private double x;
private double y;
private double velX = 0;
private double velY = 0;
private BufferedImage player;
public Player(double x, double y, Game game){
this.x = x;
this.y = y;
SpriteSheet ss = new SpriteSheet(game.getSpriteSheet());
player = ss.grabimage(1 ,1, 64, 64);
}
public void tick(){
x += velX;
y += velY;
if (x <= 0 ){
x = 0;
}
if (x >= 736){
x = 736;
}
if (y <= 0){
y = 0;
}
if (y >= 536){
y = 536;
}
}
public void render(Graphics g){
g.drawImage(player, (int)x, (int)y, null);
}
public double getX(){
return x;
}
public double getY(){
return y;
}
public void setX(double x){
this.x = x;
}
public void setY(double y){
this.y = y;
}
public void setVelX(double velX){
this.velX = velX;
}
public void setVelY(double velY){
this.velY = velY;
}
}