- Joined
- Jul 14, 2023
- Messages
- 1
- Reaction score
- 0
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!
g.getMap().print();
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 am stuck with the fundamentals and basics of a game.I will be waiting for your responses.
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!
g.getMap().print();
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.