我正在構建一個簡單的2D遊戲,我想知道是否有比我更好的編程人員可以提出設計其基本體系結構的好方法。基本遊戲考古問題
遊戲很簡單。屏幕上有多種類型的單位可以拍攝,移動和執行命中檢測。屏幕放大和縮小,屏幕側面有一個菜單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.
}
無論如何,這是所有非常基本的。只是好奇,如果有更好的方式來做到這一點。
感謝, 馬修