I am creating a simple 2d game, and I wonder if there are some better coders than I can offer a good way to develop my basic architecture.
The game is pretty simple. There are many types of units on the screen that shoot, move and perform hit detection. The screen is scaled and displayed, and there is a menu bar on the side of the screen.
The architecture that I have now looks like this:
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.
}
In any case, all this is quite simple. Just curious if there is a better way to do this.
Thanks Matthew
source
share