wiki:CodeTour
Last modified 7 months ago Last modified on 10/24/12 01:39:20

Welcome

This page will introduce you to the major structure of the Epiar code and introduce you to the major classes. Please read this before doing any hacking on Epiar, and read the CodeConventions page for important stylistic and mathematical considerations that need to be made. Also be aware of the EpiarAndGameVocabulary page, which can explain terms unfamiliar to you such as sprite or screen vs. world coordinate.

The Game Loop

What is a game loop? (skip this if you've ever made a game)

Most electronic games operate on the basic concept of a code loop (eg a while loop) that usually goes like this:

  1. Erase the screen
  2. Update all sprites (characters)
  3. Take user input (can go before step 2)
  4. Draw the screen
  5. Wait (~10ms, we do this so the loop doesn't kill the CPU)
  6. Repeat
while(!quit) {
    erase_sprites();
    quit = take_input(); // returns true if they hit 'esc'
    update_sprites();
    draw_sprites();
    sleep(10);
}

Major Classes

A Tour From Program Start Up to Gameplay

Epiar's main() function, the start of any C/C++ program, can be found in main.cpp. main() initializes the basic services, such as the logging facility (logs warning and error messages), initializes the video class, and runs the simulation.