Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package engine;
- import java.awt.event.KeyListener;
- import java.awt.event.KeyEvent;
- import java.awt.Container;
- import java.io.File;
- import graphics.main.*;
- import engine.*;
- import engine.system.*;
- import engine.system.internal.*;
- import graphics.img.fireemblem.*;
- import engine.chapterdata.*;
- //import javax.swing.*;
- public class FireEmblemEngine implements KeyListener,GameConstants,InternalCommands {
- private GameFrame frame;
- private int cursor_X = 0;
- private int cursor_Y = 0;
- private static final File eventDir = new File("engine//events");
- private EventEngine events = new EventEngine(eventDir);
- protected Map chapterMap = Map.debugMap;
- protected int chapterNum;
- //private Command internalCommand;
- protected EngineMode currentMode = EngineMode.MAP_MODE;
- public FireEmblemEngine(GameFrame frame) {
- this.frame = frame;
- }
- public FireEmblemEngine() {}
- public int getCursorX() {
- return cursor_X;
- }
- public EngineMode getCurrentMode() {
- return currentMode;
- }
- public void setCurrentMode(EngineMode em) {
- this.currentMode = em;
- }
- public int getCursorY() {
- return cursor_Y;
- }
- public void setCurrentMap(Map chapterMap) {
- this.chapterMap = chapterMap;
- }
- public Map getCurrentMap() {
- return chapterMap;
- }
- public Command returnCommand() {
- //Debug, todo
- return null;
- }
- public Command scrollMap() {
- if (cursor_Y > CURSOR_MAX_Y)
- {
- cursor_Y = CURSOR_MAX_Y;
- return Command.DOWN;
- }
- if (cursor_Y < CURSOR_MIN_Y)
- {
- cursor_Y = CURSOR_MIN_Y;
- return Command.UP;
- }
- if (cursor_X > CURSOR_MAX_X)
- {
- cursor_X = CURSOR_MAX_X;
- return Command.RIGHT;
- }
- if (cursor_X < CURSOR_MIN_X)
- {
- cursor_X = CURSOR_MIN_X;
- return Command.LEFT;
- }
- return Command.NONE;
- }
- public void runChapter() {
- //events.begin(chapterNum);
- events.runEvents(chapterNum);
- }
- public void setCurrentChapter(int chapterNum) {
- this.chapterNum = chapterNum;
- }
- public int getCurrentChapter() {
- return chapterNum;
- }
- public void keyReleased(KeyEvent x) {
- if(x.getKeyCode() == INIT_A)
- {
- frame.repaint();
- }
- if(x.getKeyCode() == KeyEvent.VK_ESCAPE)
- {
- System.exit(0);
- }
- }
- public void keyPressed(KeyEvent k) {
- if(k.getKeyCode() == INIT_A)
- {
- frame.repaint();
- }
- if(k.getKeyCode() == KeyEvent.VK_UP)
- {
- cursor_Y = cursor_Y - TILE_INCR;
- //internalCommand = null;
- frame.repaint();
- }
- if(k.getKeyCode() == KeyEvent.VK_DOWN)
- {
- cursor_Y = cursor_Y + TILE_INCR;
- frame.repaint();
- }
- if(k.getKeyCode() == KeyEvent.VK_LEFT)
- {
- cursor_X = cursor_X - TILE_INCR;
- frame.repaint();
- }
- if(k.getKeyCode() == KeyEvent.VK_RIGHT)
- {
- cursor_X = cursor_X + TILE_INCR;
- frame.repaint();
- }
- }
- public void keyTyped(KeyEvent k) { }
- }
Advertisement
Add Comment
Please, Sign In to add comment