I was asked to give a high level design of the game Asteroids. Please review the OOP design, this is not a full implementation. only the design is important here.
Please comment if the design is missing anything. or can be improved? The main problem I think is to keep Single responsibility and how to represent the entities in the vector space (this is not a simple board), I am having a hard time here not have all the parts of the game knowing each other.
public class Gameplay {
private Screenboard screenboard;
public void Move() {
// moves all entities
// spaceship moves by keyboard as for each frame it can move,
// or stay in place, or shoot
// asteroids move by AI algorithm.
}
public bool IsCollision() {
// check on the screenboards if spaceship entity collied with
// asteroids or bullet collied with asteroids
// checking by vectors
}
}wanted to know if the Gameplay should be the one that actually preform the move and check for collisions? Also how would I elaborate on the AI algorithm ? If I needed to implement this AI, how would I do it in high level details?
public class Screenboard {
private Gameplay gameplay;
private List<Bullet> bullets;
private List<Asteroid> asteroids;
public Screenboard(Gameplay _gameplay)
{
gameplay = _gameplay;
}
}Then I though having the Screenboard which should know where every entity is in the screen for letting the gameplay to make the decisions like collision detected and etc.. does it sounds okay?
public class Bullet {
// how should I represent bullet in the screenboard space as a vector
public VectorPosition position;
}
public class Asteroid {
// how should I represent asteroid in the screenboard space as a vector
public VectorPosition position;
}
public class Spaceship {
// how should I represent spaceship in the screenboard space as a vector
public VectorPosition position;
}This is the most confusing part for me. How can I represent those entities so it feels like in a real game where there is a space the asteroids moves, and a space for the spaceship to move and shoot ?
Also how can I detect collisions based on this representation ?
Anything else I might be missing here?