1
package com.brackeen.javagamebook.tilegame.sprites;
3
import com.brackeen.javagamebook.graphics.Animation;
4
import com.brackeen.javagamebook.util.MessagesSimple;
9
public class Player extends Creature {
11
private static final float JUMP_SPEED = -.95f;
13
public static boolean bGluedAllowed = true;
14
private boolean onGround;
15
private boolean bGodMode = false;
17
public void setGodMode(boolean bool) {
21
public Player(Animation left, Animation right,
22
Animation deadLeft, Animation deadRight)
24
super(left, right, deadLeft, deadRight);
25
MessagesSimple.getInstance().setTrackedSprite(this);
29
public void collideHorizontal() {
34
public void collideVertical() {
35
// check if collided with ground
36
if (getVelocityY() > 0) {
43
public void setY(float y) {
45
if (Math.round(y) > Math.round(getY())) {
52
public void wakeUp() {
58
Makes the player jump if the player is on the ground or
61
public void jump(boolean forceJump) {
62
if (onGround || forceJump) {
64
setVelocityY(JUMP_SPEED);
69
public float getMaxSpeed() {
73
public boolean isAlive() {
74
if(bGodMode) return true;
75
else return super.isAlive();
77
public void setState(int state) {
79
else super.setState(state);