I am writing a Age of Empires game but it is being played by codes but ı am stuck.

Jul 14, 2023
Reaction score
So,as i said i am writing a Age of Empires game which is visual free and played by codes.I am stuck with fundamental game logic.I don't know how to make a turn based game by OOP i searched it and i couldn't find anything.There are some instance codes that can be used for playing the game:
public static void main(String[] args) throws AgeOfEmpiresException
Game g = new Game(2); // initializes the game with 2 players (max player number is 4)
g.getPlayer(0).getWorker(0).move(1,2); // moves the first worker
g.getPlayer(1).purchase(new Cavalry()); // Second player gets a cavalry

g.getPlayer(0).getWorker(0).build(new University();// First player builds a uni.

g.getPlayer(1).getSoldier(0).move(5,5);// second player moves his soldier to 5,5 in 2d array which is map!


g2.getPlayer(0).getUniversity().trainInfantry (); // first player trains a infantry.

g2.getPlayer(0). getUniversity().trainInfantry ();// so as the first player tried to play it for twice in a single round,the game should throw AgeOfEmpiresException but the turn must still be at the first player.

The main parts that i am stuck with are:
  • I don't know how to make it turn based.(I write some codes like Player player[] = new Player(); but after that i don't know what to do.)
  • I don't know how to make a soldier or a cavalry move in a 2d array.
  • As you can see in the code there is a map which you can track the game situation.I don't know how to make a updated map after a cavarly moved to another indexes.

I am stuck with the fundamentals and basics of a game.I will be waiting for your responses.
Nov 24, 2022
Reaction score
What I would do If I were You was to start from basics. AoF - fight is not the first thing that happens. Create structure (worker) and map. You need to write alghoritm for this worker to search map for resources. If he finds it, make him to gather it. When player (all the time we talk about AI), have gothered some implement an array of workers to work together. Then You can think about buildings, army etc.
I see it this way.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Latest member

Latest Threads