K
K
Kirill Romanov2015-01-18 00:04:37
OOP
Kirill Romanov, 2015-01-18 00:04:37

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

5 answer(s)
L
lorka natas, 2015-01-19
@lorka

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.

A
Armenian Radio, 2015-01-18
@gbg

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.

W
wrench10x12, 2015-01-18
@wrench10x12

Obviously, you need to apply an object-oriented approach and represent individuals as objects

It's not at all obvious. To pile an object around, in fact, a boolean variable is a crime against common sense.
It is enough to wrap the matrix itself in an object.

M
mamkaololosha, 2015-01-18
@mamkaololosha

It is obvious that you need to use an object-oriented approach

OOP for the sake of OOP.

D
Don Kaban, 2015-01-18
@donkaban

Conway's game is a process . Not a set of objects :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question