37 lines
613 B
Java
37 lines
613 B
Java
import javax.swing.JFrame;
|
|
|
|
public class Player extends JFrame {
|
|
|
|
private static final long serialVersionUID = -6213278730749915732L;
|
|
|
|
public float speed = 0.0000003f;
|
|
|
|
public double yPos = 100;
|
|
public int ySize = 200;
|
|
|
|
public Player() {
|
|
|
|
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
this.setVisible(true);
|
|
this.setResizable(false);
|
|
|
|
}
|
|
|
|
public int getPos(long dt, boolean up, boolean down) {
|
|
|
|
// System.out.println(yPos);
|
|
|
|
if(yPos > 850) {
|
|
yPos = 850;
|
|
}
|
|
|
|
if (up) {
|
|
yPos -= speed * dt;
|
|
} else if (down && yPos < 850) {
|
|
yPos += speed * dt;
|
|
}
|
|
return (int) yPos;
|
|
}
|
|
|
|
}
|