Sea war game questions

Good day. I have a question about the structure of the program. I’m making a game based on sea battle mechanics. Ships will have various properties such as counterattack or evasion. There will be 4 types of ships with a unique set of properties. Also, ships in certain positions will acquire additional properties (again, unique for their type). And there will be a bonus weapon that opens not one cell, but several.

Please tell me how to implement it correctly. The game will be against AI. At this point, it’s also not clear to me how the switch between the player’s turn and the AI ​​will take place.

I already tried to write this game, but the code was terrible, I had to invent something (patches) on the fly to somehow work. For example, I hung a listener on the cells of the AI ​​​​field, and when I did a tap in the shot processing procedure, I called the player’s firing function.

Your question is too broad for a meaningful response. There are hundreds of interconnected decisions to be made when you program something, but no “correct” way to structure a program. There are best practices, and there are certainly “incorrect” things that don’t work, but if you need help with an overall strategy for structuring your program, you should probably do some tutorials or start off writing something smaller to get a better understanding about how to organize a game.

We can best help you with specific problems- like, “Here’s a function I wrote, I want it to do X, but it doesn’t work. What’s wrong?”

If you haven’t done many tutorials, and are interested in the basic structure of a game, I think this tutorial is a good place to start:

1 Like