/*
   CMSC 427 - Term Project Candidate
   ---------------------------------

   Beth Weinstein - bweinste@wam.umd.edu
   Ben Stewart - stewartb@wam.umd.edu
   Nawfel Tricha - Topaz@endorproductions.com

   Minimal OpenGL project using Microsoft Visual C++.
   This project is a premilinary candidate for the term 
   project required by CMSC 427.

   ABSTRACT:
      In this project, we will develop several fast 
      rendering and collision routines which would 
      require C/C++ speed and accuracy and then 
      implement a VisualJ++ interface.

   MODULE:
      Ben Engine module.
*/

#include "Global.h"

static skin_t r_floor_skin;
#define NUM_SNORKS 5
/* BS: So far I've worked with three characters */
static edict_t *snorks[NUM_SNORKS];
static edict_t *bobaFett, *chunLi, *slingShot, *snork, *left_table, *right_table,
			   *center_table, *snork_table;

#define BEN_STZ_SHOW_SLING_SHOT			 4
#define SLING_SHOT_STANZA_LENGTH		   20
#define BEN_STZ_SHOW_SNORK				    5
#define SNORK_STANZA_LENGTH				10
#define BEN_STZ_SHOW_BOBA_FETT          6
#define BOBA_FETT_STANZA_LENGTH			10


#define DISCO   0
#define TUXEDO  1
#define DUKE    2
#define HARRYIT 3
#define MRPANTS 4


/*
   Initialization of Ben engine:
*/
void BenInit()
{   
	int i;

	bobaFett = BobaFettSpawn();
	snork = SnorkSpawn();
	snork->skin_num = DISCO;
	
	slingShot = SlingShotSpawn();

	for(i = 0; i < NUM_SNORKS; i++)
	{
		snorks[i] = SnorkSpawn();
	}
	snorks[0]->angle[YAW] = -90;
	snorks[0]->skin_num = HARRYIT;
	VectorSet(snorks[0]->origin, (-408 + 75) * 0.4f, 7, 10);
	snorks[1]->angle[YAW] = -90;
	snorks[1]->skin_num = DUKE;
	VectorSet(snorks[1]->origin, (-408 + 75) * 0.4f, 7, -10);
	snorks[2]->angle[YAW] = 90;
	snorks[2]->skin_num = TUXEDO;
	VectorSet(snorks[2]->origin, (408 - 75) * 0.4f, 7, 10);
	snorks[3]->angle[YAW] = 90;
	snorks[3]->skin_num = HARRYIT;
	VectorSet(snorks[3]->origin, (408 - 75) * 0.4f, 7, -10);
	snorks[4]->angle[YAW] = 180;
	snorks[4]->skin_num = MRPANTS;
	VectorSet(snorks[4]->origin, 10, 7, (-400 + 75) * 0.4f);

	left_table = TableSpawn();
	VectorSet(left_table->origin, (-408 + 75) * 0.4f, 0, 0);
	right_table = TableSpawn();
	VectorSet(right_table->origin, (408 - 75) * 0.4f, 0, 0);
	center_table = TableSpawn();
	VectorSet(center_table->origin, 0, 0, (-400 + 75) * 0.4f);
	snork_table = TableSpawn();
	VectorSet(snork_table->origin, -17, 0, -58);
}

/*
   Stanza change for Ben engine:
*/
void BenStanza(int stanza)
{
   switch (stanza)
      {
	   // SHow Snork for 20 seconds:
	  case BEN_STZ_SHOW_SNORK:
		  cam.target = snork;
		  eng.next_stanza = eng.time + (1000 * SNORK_STANZA_LENGTH);
		  break;
      // Show Boba Fett for 15 seconds:
      case BEN_STZ_SHOW_BOBA_FETT:
		  cam.target = bobaFett;
		  eng.next_stanza = eng.time + (1000 * BOBA_FETT_STANZA_LENGTH); 
		  break;
	  // Show Sling Shot for 45 seconds:
	  case BEN_STZ_SHOW_SLING_SHOT:
		  cam.target = slingShot;
		  eng.next_stanza = eng.time + (1000 * SLING_SHOT_STANZA_LENGTH);
		  break;
     default:
         stanza = 0;
      }

}


/*
   Main function, called from RenderFrame every frame:
*/
void BenMain(struct winampVisModule *this_mod)
{
}

