Answer the question
In order to leave comments, you need to log in
How to implement the architecture of the game?
I decided to make another version of the game "Life", this time on Qt (before that I did it on pure C). I don't understand how to do it right. Obviously, you need to apply an object-oriented approach and represent individuals as objects of a certain class, placed inside some kind of table or matrix. But how to implement the interaction of these individuals? That is, the individual must know what is next to it, in neighboring cells of the table.
Upd. I want to use OOP, because I'm going to make a more advanced version, with all sorts of characteristics, mutations, crossbreeding, etc.
Answer the question
In order to leave comments, you need to log in
Create a class "bacteria", indicating the coordinates, "level", a unique ID (useful in the future). In the main class, create a collection (like Map) and a procedure for checking the conditions of "life", add a timer. Enter in Map with a key like "coordinateX-coordinateY" (to find "neighbors" by this key). In the timer, iterate over the collection, with the result being drawn at the end - visualization to taste (at least OpenGL). For "extensibility" and "mutation" capabilities - it is desirable to already use the parent and child classes, then you can describe the different types of "monsters" and their unique behavior.
Create a grid in the form of an array of instances of the Cell class.
Then, by signals, you bind each cell to its neighbors using the connect method.
You bind all cells with the tick slot to the timer. In this slot, you organize tick processing and polling neighbors.
From all cells, bind the draw signal to something table-like. To draw.
Obviously, you need to apply an object-oriented approach and represent individuals as objects
It is obvious that you need to use an object-oriented approach
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question