<file_sep>package com.game.gameobject;

import com.game.state.GameState;

public abstract class Bullet extends SpecificObject {

	public Bullet(float posX, float posY, float width, float height, float mass, int healthPoint, int manaPoint,
			GameState gameState) {
		super(posX, posY, width, height, mass, healthPoint, manaPoint, gameState);
		// TODO Auto-generated constructor stub
	}

	
}
<file_sep>package com.game.gameobject;

import java.awt.Graphics;
import java.awt.Rectangle;

import com.game.gameinteface.Actable;
import com.game.state.GameState;

public abstract class HumanoidObject extends SpecificObject implements Actable{
	
	private boolean isJumping;
	private boolean isKneeling;
	private boolean isLanding;

	public HumanoidObject(float posX, float posY, float width, float height, float mass, int healthPoint, int manaPoint,
			GameState gameState) {
		super(posX, posY, width, height, mass, healthPoint, manaPoint, gameState);
		setState(ALIVE);
	}
	
	@Override
	public void Update() {
		
		super.Update();
		
		
		
	}

	public boolean isJumping() {
		return isJumping;
	}

	public void setJumping(boolean isJumping) {
		this.isJumping = isJumping;
	}

	public boolean isKneeling() {
		return isKneeling;
	}

	public void setKneeling(boolean isKneeling) {
		this.isKneeling = isKneeling;
	}

	public boolean isLanding() {
		return isLanding;
	}

	public void setLanding(boolean isLanding) {
		this.isLanding = isLanding;
	}
}
<file_sep>package com.game.gameinteface;

import java.awt.Graphics;

public interface ButtonState {

	public static final int NONE = 0;
	public static final int PRESS = 1;
	public static final int HOVER = 2;
	
	public abstract boolean isInButton();
	
	public abstract void draw(Graphics g);
	
}
<file_sep>package com.game.userinterface;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JPanel;

import com.game.state.MenuState;
import com.game.state.State;

// Status: unfinished
// Con ham paint va ham run chua hoan thien

public class GamePanel extends JPanel implements KeyListener, Runnable {

	State gameState;
	
	KeyEventManager keyEventManager;
	
	private Thread thread;
	private boolean isRunning;
	
	public GamePanel() {
		
		gameState = new MenuState(this);
		keyEventManager = new KeyEventManager(gameState);
		
	}

	@Override
	public void paint(Graphics g) {
		g.setColor(Color.GRAY);
		g.fillRect(0, 0, GameFrame.SCREEN_WIDTH, GameFrame.SCREEN_HEIGHT);
	}
	
	public void startGame() {
		if(thread == null) {
			thread = new Thread(this);
			isRunning = true;
			thread.start();
		}
	}
	
	public void setState(State state) {
		this.gameState = state;
		keyEventManager.setState(state);
	}
	
	@Override
	public void keyTyped(KeyEvent e) {}

	@Override
	public void keyPressed(KeyEvent e) {
		// TODO Auto-generated method stub
		System.out.println("You pressed");
		keyEventManager.processKeyPressed(e.getKeyCode());
	}

	@Override
	public void keyReleased(KeyEvent e) {
		// TODO Auto-generated method stub
		System.out.println("You released");
		keyEventManager.processKeyReleased(e.getKeyCode());
	}

	@Override
	public void run() {
		// TODO Auto-generated method stub
		long FPS = 80;
		long period = 1000000000 / FPS;
		
		long previousTime = System.nanoTime();
		long sleepTime;
		long currentTime;
		
		while(isRunning) {
			//Update
			//Render
			
			repaint();
			currentTime = System.nanoTime();
			
			sleepTime = period - (currentTime - previousTime);
			
			try {
				if(sleepTime > 0)
					thread.sleep(sleepTime/1000000);
				else thread.sleep(period/2000000);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
}
<file_sep>package com.game.gameobject;

import java.awt.Rectangle;

import com.game.effect.Animation;
import com.game.gameinteface.Profile;
import com.game.gameinteface.Vulnerable;
import com.game.state.GameState;

// Status: Con PT isOutOfCameraView va Update

public abstract class SpecificObject extends GameObject implements Profile, Vulnerable  {

	private int state = ALIVE;
	private int teamType;
	private int direction;
	
	private float width;
	private float height;
	private float speedX;
	private float speedY;
	private float mass;
	
	private int healthPoint;;
	private int manaPoint;
	private int damage;
	
	private long beginTimeToNoBeHurt;
	private long timeForNoBeHurt;
	
	protected Animation beHurtForward, beHurtBackward;;
	
	public SpecificObject(float posX, float posY, float width, float height, float mass, int healthPoint, int manaPoint, GameState gameState) {
		super(posX, posY, gameState);
		setWidth(width);
		setHeight(height);
		setMass(mass);
		setHealthPoint(healthPoint);
		setManaPoint(manaPoint);
		
		direction = RIGHT_DIR;
		
	}
	
	public boolean isOutOfCameraView() {
		// Can Camera
		return false;
	}
	
	public void beHurt (int damageRecieved) {
		setHealthPoint(getHealthPoint() - damageRecieved);
		state = BEHURT;
	}
	
	public Rectangle getBoundForCollisionWithMap() {
		Rectangle rect = new Rectangle();
		
		rect.x = (int) (getPosX() - getWidth()/2);
		rect.y = (int) (getPosY() - getHeight()/2);
		rect.width = (int) getWidth();
		rect.height = (int) getHeight();
		
		return rect;
	}

	@Override
	public void Update() {
		switch(state) {
		
		case ALIVE: 
			
			// Cho SpecificObjectManager
			
			break;
			
		case BEHURT:
			
			if(beHurtBackward == null) {
				state = CANTBEHURT;
				beginTimeToNoBeHurt = System.nanoTime();
				if(getHealthPoint() == 0) {
					state = FEY;
				}
			} else {
				beHurtForward.Update(System.nanoTime());
				if(beHurtForward.isLastFrame()) {
					beHurtForward.reset();
					state = CANTBEHURT;
					if(getHealthPoint() == 0) {
						state = FEY;
						beginTimeToNoBeHurt = System.nanoTime();
					}
				}
			}
			
			break;
			
		case FEY:
			
			state = DEATH;
			
			break;
			
		case CANTBEHURT:
			
			if(System.nanoTime() - beginTimeToNoBeHurt > timeForNoBeHurt) {
				state = ALIVE;
			}
			
			break;
			
		case DEATH:
			break;
		
		}
	}
	
	public int getState() {
		return state;
	}

	public void setState(int state) {
		this.state = state;
	}

	public int getTeamType() {
		return teamType;
	}

	public void setTeamType(int teamType) {
		this.teamType = teamType;
	}

	public int getDirection() {
		return direction;
	}

	public void setDirection(int direction) {
		this.direction = direction;
	}

	public float getWidth() {
		return width;
	}

	public void setWidth(float width) {
		this.width = width;
	}

	public float getHeight() {
		return height;
	}

	public void setHeight(float height) {
		this.height = height;
	}

	public float getSpeedX() {
		return speedX;
	}

	public void setSpeedX(float speedX) {
		this.speedX = speedX;
	}

	public float getSpeedY() {
		return speedY;
	}

	public void setSpeedY(float speedY) {
		this.speedY = speedY;
	}

	public float getMass() {
		return mass;
	}

	public void setMass(float mass) {
		this.mass = mass;
	}

	public int getHealthPoint() {
		return healthPoint;
	}

	public void setHealthPoint(int healthPoint) {
		if(healthPoint >= 0)
			this.healthPoint = healthPoint;
		else this.healthPoint = 0;
	}

	public int getManaPoint() {
		return manaPoint;
	}

	public void setManaPoint(int manaPoint) {
		if(manaPoint >= 0)
			this.manaPoint = manaPoint;
		else this.manaPoint = 0;
	}

	public int getDamage() {
		return damage;
	}

	public void setDamage(int damage) {
		this.damage = damage;
	}

	public long getBeginTimeToBeHurt() {
		return beginTimeToNoBeHurt;
	}

	public void setBeginTimeToBeHurt(long beginTimeToBeHurt) {
		this.beginTimeToNoBeHurt = beginTimeToBeHurt;
	}

	public long getTimeForNoBeHurt() {
		return timeForNoBeHurt;
	}

	public void setTimeForNoBeHurt(long timeForNoBeHurt) {
		this.timeForNoBeHurt = timeForNoBeHurt;
	}
}
<file_sep>package com.game.state;

import com.game.userinterface.GamePanel;

public class MenuState extends State{

	public MenuState(GamePanel gamePanel) {
		super(gamePanel);
	}
	
	public void processPressButton(int keyEvent) {
		
	}
	
	public void processReleaseButton(int keyEvent) {
		
	}

	@Override
	public void Update() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void Render() {
		// TODO Auto-generated method stub
		
	}
}
<file_sep>package com.game.state;

import com.game.userinterface.GamePanel;

public abstract class State {

	public State(GamePanel gamePanel) {
		// TODO Auto-generated constructor stub
	}
	
	public abstract void Update();
	
	public abstract void Render();
	
	public abstract void processPressButton(int keyEvent);
	
	public abstract void processReleaseButton(int keyEvent);
	
}
<file_sep>package com.game.userinterface;

import java.io.IOException;

import javax.swing.JFrame;

import com.game.effect.DataLoader;

//  Status: Completed

public class GameFrame extends JFrame {
	
	public static final int SCREEN_WIDTH = 1000;
	public static final int SCREEN_HEIGHT = 750;
	
	GamePanel gamePanel;
	
	public GameFrame() {
		
		gamePanel = new GamePanel();
		
		setSize(SCREEN_WIDTH, SCREEN_HEIGHT);
		setLocationRelativeTo(null);
		setVisible(true);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		try {
			DataLoader.getInstance().LoadData();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		add(gamePanel);
		addKeyListener(gamePanel);
		
	}
	
	public void startGame() {
		gamePanel.startGame();
	}
	
	public static void main(String[] args) {
		GameFrame gameFrame = new GameFrame();
		gameFrame.startGame();
	}
}
<file_sep>package com.game.objectmanager;

public class SpecificObjectManager {

}
<file_sep>package com.game.effect;

import java.awt.Graphics;
import java.awt.image.BufferedImage;

// Status: Completed

public class FrameImage {

	private String name;
	private BufferedImage image;
	
	public FrameImage() {
		// TODO Auto-generated constructor stub
		this.image = null;
		this.name = null;
	}
	
	public FrameImage(String name, BufferedImage image) {
		// TODO Auto-generated constructor stub
		this.name = name;
		this.image = image;
	}
	
	public FrameImage(FrameImage frameImage) {
		// TODO Auto-generated constructor stub
		image = new BufferedImage(frameImage.getImage().getWidth(), frameImage.getImage().getHeight(), frameImage.getImage().getType());
		
		Graphics g = image.getGraphics();
		g.drawImage(frameImage.getImage(), 0, 0, null);
		this.name = frameImage.name;
		
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public BufferedImage getImage() {
		return image;
	}

	public void setImage(BufferedImage image) {
		this.image = image;
	}
	
}
<file_sep>package com.game.gameobject;

import java.awt.Graphics;

public class BackgroundMap extends GameObject{

	@Override
	public void Update() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void draw(Graphics g) {
		// TODO Auto-generated method stub
		
	}

}
