/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package net.kirauks.minigames.engine;

import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;

/**
 *
 * @author Karl
 */
abstract class GameApplication extends Application{
    @Override
    public void start(Stage stage) throws Exception {
        stage.setTitle(this.createStageTitle());
        
        Scene scene = this.createScene();        
        stage.setScene(scene);
        stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
            @Override
            public void handle(WindowEvent t) {
                GameApplication.this.onCloseStage();
            }
        });
        
        stage.show();
    }
    
    /**
     * Called on Stage creation, the returned String will be used as Stage's title.
     * 
     * @return The used stage title; 
     */
    public abstract String createStageTitle();
    
    /**
     * Called on Scene adding during the Stage creation process, the returned Scene will be added to the Scene.
     * 
     * @return 
     */
    public abstract Scene createScene();
    
    /**
     * Called on GameApplication close;
     */
    public abstract void onCloseStage();
    
    /**
     * Called on Game pause.
     */
    public abstract void onPauseGame();

    /**
     * Called on Game resume.
     */
    public abstract void onResumeGame();
}

@@ -337,51 +337,173 @@
 fx.s
-tage.Stage;%0Aimport javafx.stage.WindowEvent
+cene.input.KeyCode;%0Aimport javafx.scene.input.KeyEvent;%0Aimport javafx.stage.Stage;%0Aimport javafx.stage.WindowEvent;%0Aimport net.kirauks.minigames.engine.utils.Options
 ;%0A%0A/
@@ -579,16 +579,20 @@
 ication%7B
+    
 %0A    @Ov
@@ -751,16 +751,1261 @@
 Scene();
+    %0A        %0A        scene.setOnKeyPressed(new EventHandler%3CKeyEvent%3E()%7B%0A            @Override%0A            public void handle(KeyEvent t) %7B%0A                KeyCode key = t.getCode();%0A                if(key.equals(Options.getActionKey()))%7B%0A                    GameApplication.this.onActionKeyPressed();%0A                %7D%0A                else if(key.equals(Options.getUpKey()))%7B%0A                    GameApplication.this.onUpKeyPressed();%0A                %7D%0A                else if(key.equals(Options.getDownKey()))%7B%0A                    GameApplication.this.onDownKeyPressed();%0A                %7D%0A                else if(key.equals(Options.getLeftKey()))%7B%0A                    GameApplication.this.onLeftKeyPressed();%0A                %7D%0A                else if(key.equals(Options.getRightKey()))%7B%0A                    GameApplication.this.onRightKeyPressed();%0A                %7D%0A            %7D%0A        %7D);%0A        scene.setOnKeyReleased(new EventHandler%3CKeyEvent%3E()%7B%0A            @Override%0A            public void handle(KeyEvent t) %7B%0A                KeyCode key = t.getCode();%0A                if(key.equals(Options.getActionKey()))%7B%0A                    GameApplication.this.onActionKeyReleased();%0A                %7D%0A            %7D%0A            %0A        %7D);%0A
         
@@ -2697,59 +2697,130 @@
     
-/**%0A     * Called on GameApplication close
+public abstract void onCloseStage();%0A    public abstract void onPauseGame();%0A    public abstract void onResumeGame()
 ;%0A    
- */
 %0A   
@@ -2847,158 +2847,208 @@
 d on
-CloseStage();%0A    %0A    /**%0A     * Called on Game pause.%0A     */%0A    public abstract void onPauseGame();%0A%0A    /**%0A     * Called on Game resume.%0A     */
+ActionKeyPressed();%0A    public abstract void onActionKeyReleased();%0A    public abstract void onUpKeyPressed();%0A    public abstract void onDownKeyPressed();%0A    public abstract void onLeftKeyPressed();
 %0A   
@@ -3068,27 +3068,32 @@
 act void onR
-esumeGame
+ightKeyPressed
 ();%0A%7D%0A

Add key handling