Hey Folks, I'm building a simple 2d game,and I'm wondering if some better coders than I can suggest a good way to design its basic architecture.
The game is pretty simple. There are many types of units on the screen which shoot, move, and perform hit detection. The screen zooms in and out, and there is a menu UI bar on the side of the screen.
The architecture 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.
}
Anyway, this is all pretty basic. Just curious if there is a better way to be doing this.
Thanks, Matthew