私はシンプルな2次元ゲームを構築しています。私は基本的なアーキテクチャを設計する良い方法を提案できると思っています。基本的なゲームの構造の質問
ゲームはかなりシンプルです。撮影、移動、ヒット検出を実行する画面には、多くの種類のユニットがあります。画面がズームイン/ズームアウトし、画面の横にメニューUIバーがあります。
私が持っているアーキテクチャは、次のようになります。
とにかくLoad a "stage".
Load a UI.
Have the stage and UI pass references to each other.
Load a camera, feed it the "stage" as a parameter. Display on screen what the camera is told to "see"
Main Loop {
if (gameIsActive){
stage.update()
ui.update()
camera.updateAndRedraw()
}
}else{
if (!ui.pauseGame()){
gameIsActive=true
}
if(ui.pauseGame()){
gameIsActive=false
}
stage update(){
Go through a list of objects on stage, perform collision detection and "action" checks.
objects on stage are all subclasses of an object that has a reference to the stage, and use that reference to request objects be added to the stage (ie. bullets from guns).
}
ui update(){
updates bars, etc.
}
、これはすべての非常に基本的なものです。これを行うにはより良い方法があるかどうか不思議です。
おかげで、 マシュー