2. The "game loop"

The main part of a game is a loop, which repeats a series of actions, which tipically are:

In the first approach, we will make our game is repeated indefinitely, with a condition like "while (1==1)".

Most of the tasks of this "game loop" will be completed later, and now they will be commented out, so that the source "remember" what will end up being.

The result could be something like:

/*
  First mini-console-game skeleton
  Version C: "game loop"
*/
 
using System;
 
public class Game01c
{
    public static void Main()
    {
        int x=40, y=12;
 
        // Game Loop
        while( 1 == 1 )
        {
            // Draw
            Console.Clear();
            Console.SetCursorPosition(x, y);
            Console.Write("C");
 
            // Read keys and calculate new position
            // TO DO
 
            // Move enemies and environment
            // TO DO
 
            // Collisions, lose energy or lives, etc
            // TO DO
 
            // Pause till next fotogram
            // TO DO
        }
    }
}
 

Suggested exercise: Use a "bool" variable to control the game loop (right now, this variable will have "true" as a statring value, which will not change).