Beispiel #1
0
int main(int argc, char* args[])
{
	FileParser fp;
	TokenList list = fp.tokenize(args[1]);
	LevelCreator lc;

    Course course = lc.createCourse(list);
    
	// Start SDL
	if (!init(argc, args)) {
		system("pause");
		exit(0);
	}

	// Load sound files for audio
	if (!Audio::loadMedia()){
		exit(0);
	}
    
	// Main Loop
	else {
		Mix_PlayMusic(Audio::gMusic, -1);
		float start_time_ms = SDL_GetTicks();
		float prev_time = start_time_ms;
		float curr_time;
		float delta_time = 10;

		while (!quit) {
			// Make sure we referance the correct level
			Level test = course.levels[GameInfo::currLevel];

			// Update game time
			curr_time = SDL_GetTicks() - start_time_ms;
			delta_time = curr_time - prev_time;

			// Process Events
			handleEvents(test);

			// Update
			update(delta_time, test);

			// Draw
			draw(test);

			// Play music if stopped
			if (Mix_PlayingMusic() == 0){
				Mix_PlayMusic(Audio::gMusic, -1);
			}

			// Set previous time
			prev_time = curr_time;
		}
	}

	// Free and close
	close();
	return 0;
}