Skip to content

split every game loop / screen loop to a separate function in Chess.c:main #3

@rodikh

Description

@rodikh

In the main function of your Chess.c file, you have 3 game loops inside one main loop.
It is always a good idea to separate these loops to different functions. it will keep your main function short and readable.

i.e. instead of reading a huge function that has many ifs and whiles, you can see a short function like this:

if (game_mode == SETTINGS){
  settingsScreen();
} else if (game_mode == TWO_PLAYER) {
  gameScreen(TWO_PLAYER);
} else if (game_mode == PLAYER_VS_COMP) {
  gameScreen(PLAYER_VS_COMP);
}

once again, since the loops for the pvp and pvc are nearly identical, you can write the code once, and have parameters decide what to do inside the function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions