JME 배우기 - 2(The Main Game Loop) - AbstractGame,BaseGame
The Main Game Loop
보통의 게임의 시작은 다음과 같다.
시작 - 초기화 - Update Game - Draw Scene - Clean up - Stop
물론 Update Game 전과 Clean up은 루프로 사용자가 원할대까지 계속 반복되어야 한다.
AbstractGame 을 상속받아야 하는데, 상속을 받으면 아래에 해당하는 기능을
반드시 구현해야한다. 물론 이걸 직접적으로 가져다 쓸수없다.
이걸 상속하여 어느정도 구현한 클래스를 상속해서 개발해야한다.
아래가 AbstractGame에 선언되어 있는거다.
setDialogBehaviour 라 , 게임창을 띄우기 위한 값을 셋팅하는 곳이다.
여기에 저장하는 값이 있는데
NEVER_SHOW_PROPS_DIALOG : 창자체를 안보여주는것 같고,
FIRSTRUN_OR_NOCONFIGFILE_SHOW_PROPS_DIALOG : 첫실행에서만 보여주고, 그다음은 안보여주고
ALWAYS_SHOW_PROPS_DIALOG : 항상 보여주네.
로 셋팅한다.
이걸로 다음과 같은 창을 띄운다.
항상 개발할때 위와같은 것은 필요없으닌 실제 개발해서 아우풋을 낼때는
NEVER_SHOW_PROPS_DIALOG 이거겠지.
이미지 인자는 저거의 로고를 바꾸기 위한거고,
아래는 AbstractGame Javadoc이다.
void |
finish() finish breaks out of the main game loop. |
java.lang.String |
getVersion() getVersion returns the version of the API. |
void |
setDialogBehaviour(int behaviour) setDialogBehaviour defines if and when the display properties dialog should be shown. |
void |
setDialogBehaviour(int behaviour, java.lang.String image) setDialogBehaviour defines if and when the display properties dialog should be shown as well as its accompanying image. |
void |
setDialogBehaviour(int behaviour, java.net.URL image) setDialogBehaviour sets how the properties dialog should appear. |
abstract void |
start() start begins the game. |
자자 다음은, BaseGame 이란건데, AbstractGame 을 상속받아 구현한 클래스이다. 그저 빠르게 로딩시켜주고, AbstractGame 의 메소드를 재정의(또다시 abstract이다.)했다는것 뿐이다.
이걸 상속받은 클래스는 다시 메소드를 재정의 해야한다.
다음은 SimpleGame 인데, BaseGame를 상속받아 구현한 이른바 프로토 타입이다. 이걸로 일반적인 키입력 이벤트나 그래픽처리등을 수행할수 있다.
다음은 SimpleGame에 구현되어 있는 키이벤트 내용이다.
Key | Action |
---|---|
W | Move Forward |
A | Strafe Left |
S | Move Backward |
D | Strafe Right |
Up | Look Up |
Down | Look Down |
Left | Look Left |
Right | Look Right |
T | Wireframe Mode on/off |
P | Pause On/Off |
L | Lights On/Off |
C | Print Camera Position |
B | Bounding Volumes On/Off |
N | Normals On/Off |
F1 | Take Screenshot |
총체적인 구조도는 다음과 같다.
java.lang.Object
com.jme.app.AbstractGame
com.jme.app.BaseGame
com.jme.app.SimpleGame
다음에는 simpleGame 에 대해 분석좀 해봐야 겠다.