Answer the question
In order to leave comments, you need to log in
How to properly build the architecture of a console game?
Hello! I developed the console game "Snake", the teacher said that it is necessary to build the correct architecture of the game so that it does not depend on the console and can, if necessary, simply be converted to WinForm. A prerequisite is the use of delegates and events.
As far as I understand, the architecture should be like this:
Class "Food": generating food coordinates, rendering food.
Class "Obstacle": generation of obstacle coordinates, rendering of obstacles.
Class "Snake": initialization of the initial coordinates of the snake, change of direction by 1 familiarity (up, down, right, left), and a method that increases the snake.
Class "Game": works with all these classes.
The problem is that building a good architecture is not yet my strongest side. Please push me how to properly build the interaction of events and classes.
Answer the question
In order to leave comments, you need to log in
Separate logic from visualization. That is, let's say there is a snake class. It has move events. Subscribe to snake events. When triggered, we get its position from passing them to the visualization class.
For the console, this will be one class, for winforms another, and so on. All rendering classes will need to implement a common interface.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question