コード例 #1
0
ファイル: game.cpp プロジェクト: Ace-HasIssuesToo/test
void mapseq()
{
	switch(next)
	{
		case 0:menu();sidemenu();break;
		case 98:levelskip();break;
		case 1:level1();break;
		case 2:level2();break;
		case 3:level3();break;
		case 4:level4();break;
		case 5:level5();break;
		case 101:levelskip();break;
		case 6:level6();break;
		case 7:level7();break;
		case 8:level8();break;
		case 9:level9();break;
		case 10:level10();break;
		case 102:levelskip();break;
		case 11:level11();break;
		case 12:level12();break;
		case 13:level13();break;
		case 14:level14();break;
		case 15:level15();break;
		case 103:levelskip();break;
		case 16:win();break;
		case 99:help();break;
		case 100:lose();elapsedTime=0;break;
	}
}
コード例 #2
0
ファイル: polynom.cpp プロジェクト: caseymcspadden/IRPSIM
void CMPolynomial::level7(double& result)      // functions, (), numbers,
{                                            // user functions, parameters
	if (token == LPar || token == LBracket) {
		get_token();
		level1(result);
	}
	else if (token == If)
		result = eval_condition();
	else if (token == Function)
		result = eval_function();
	else if (token==Variable||token==VariableOrig)
		result = eval_variable(token==Variable);
	else if (token == Constant)
		result = constants[offset];
	/*
	else if (token == Definition) 
	{
		result = CMDefinitions::GetDefinitionValue(offset);
		sdebug << "Definition " << offset << result << ENDL;
	}
	*/
	else if (isspecialfunc(token))
		result = eval_special_function();
	get_token();
}
コード例 #3
0
ファイル: ptv.c プロジェクト: 3dptv/command_line
//int tracking(ClientData clientData, Tcl_Interp* interp, int argc, const char** argv)
int tracking( int argc, const char** argv)
{
 level1();
 level2();
 level3();

 return 0;
}
コード例 #4
0
ファイル: deepsample.cpp プロジェクト: Go-LiDth/platform
int
main(int argc, char ** argv)
{
    std::cout << "I'm such a _deep_ sample" << std::endl;
    level1();
    level2();    
    return 0;
}
コード例 #5
0
int get_exp(double *hold)
{
	code = 0;

	get_token();
	if (!*(token))
	{
		return 0;
	}
	level1( hold);
	putback();
  return code==0;
}
コード例 #6
0
void level6(double *hold)
{
	if ((*(token) == '(') && ((token_type) == DELIMITER))
	{
		get_token();
		level1( hold);
		if (*(token) != ')')
			  serror( ERR_NOBRACKET);
		get_token();
	}
	else
		primitive( hold);
}
コード例 #7
0
ファイル: polynom.cpp プロジェクト: caseymcspadden/IRPSIM
double CMPolynomial::Evaluate(CMTimeMachine* t)
{
	if (Fail())
		return 0;

	time  = t;
	index = 0;
	double r;

	get_token();

	level1(r);

	return r;
}
コード例 #8
0
ファイル: smallcalc.cpp プロジェクト: D-POWER/smallcalc
float smallcalc::Parser::level4()
{
	float ans;
	if (token_type == OPEN_PARENTHESIS)
	{
		next_token();
		ans = level1();
		if (token_type != CLOSE_PARENTHESIS)
			throw std::domain_error("Missing close parenthesis");
        else
            next_token();
	}
	else
		return get_number();
	return ans;
}
コード例 #9
0
ファイル: smallcalc.cpp プロジェクト: D-POWER/smallcalc
float smallcalc::Parser::parse(char *expr)
{
	try
	{
		strcpy(m_expr, expr);
		m_cursor = m_expr;
		strcpy(token_value, "");
		token_type = UNDEFINED;
		next_token();
		return level1();
	}
	catch (const std::exception &e)
    {
        std::cout << e.what() << std::endl;
    }
    return 0.0f;
}
コード例 #10
0
ファイル: main.c プロジェクト: melbcat/sdg_final
void start()
{
    if (!CHEAT) {
        level1();
        return;
    }

    init_map();
    int goal = count_goal();
    if (goal == 0) {
        myprintf("It's impossible to win the game.\n");
    } else if (play(goal)) {
        myprintf("Congraz! You pass %d! XD\n", goal);
        set_bestscore();
    } else
        myprintf("You lose. What a pity.\n");
    
}
コード例 #11
0
ファイル: pacman.cpp プロジェクト: koomahnah/piGame
void pacmanGame()
{
	lcdSetBackgroundColour(BACKGROUND_COLOUR);
	lcdSetFontColour(FOREGROUND_COLOUR);
	lcdSetCursor(0, 0);
	lcdPixelsDraw(240 * 320, BACKGROUND_COLOUR);
	lcdPrint(10, 10, "PACMAN");
	wait(1000000);
	lcdPrint(50, 10, "MOVE WITH 2,4,5,6");
	wait(1000000);
	lcdPrint(76, 10, "PRESS A TO START");
	while (kBuffer != 3)
		continue;
	kBuffer = 16;
	lcdFillWindow(0, 239, 0, 319, BACKGROUND_COLOUR);
	lcdPrint(112, 80, "LEVEL 1");
	wait(1000000);
	pacman::lifes = 3;
	while (1) {
		if (level1()) {
			pacman::lifes = 3;
			pacman::score = 0;
			continue;
		}
		if (level2()) {
			pacman::lifes = 3;
			pacman::score = 0;
			continue;
		}

		if (level3()) {
			pacman::lifes = 3;
			pacman::score = 0;
			continue;
		}

		if (level4()) {
			pacman::lifes = 3;
			pacman::score = 0;
			continue;
		}
	}

}
コード例 #12
0
int main()
{
	Level level1(2);
	while(true)
	{
		level1.draw_level(std::cout);
		level1.update_level();
		if(level1.level_end())
		{
			//only had time to implement a simple 1 level game with 2 zombies rather than a 
			//continuing game.
			if(level1.did_player_win())
			{
				std::cout << "Congrats! you won!" << std::endl;
			}
			else
			{
				std::cout << "Ahhhhhh, you got eaten by zombies!" << std::endl;
			}
			break;
		}
	}
}
コード例 #13
0
int main(int argc, char *argv[])
{
  KAboutData aboutData("crashtext", "Crash Test for DrKonqi",
                       "1.1",
                       "Crash Test for DrKonqi",
                       KAboutData::License_GPL,
                       "(c) 2000-2002 David Faure, Waldo Bastian");

  KCmdLineArgs::init(argc, argv, &aboutData);
  KCmdLineArgs::addCmdLineOptions(options);

  KApplication app(false, false);
  KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
  QCString type = args->count() ? args->arg(0) : "";
  int crashtype = Crash;
  if (type == "malloc")
    crashtype = Malloc;
  else if (type == "div0")
    crashtype = Div0;
  else if (type == "assert")
    crashtype = Assert;
  level1(crashtype);
  return app.exec();
}
コード例 #14
0
void calc_function(double *hold)
{
  double_list *args = NULL, *last = NULL, *t;		
  double d;
	int i,argc=0,save_code;

	save_code = code;
	code = 0;
	i = look_up(token);

	if (i == 0)
		serror(ERR_BADFUNCTION);	// error

	get_token();
	if (*(token) != '(')
		serror(ERR_NOBRACKET);	// error
	//get_token();
	if (functions[i].args == STR_ARG)
	{
		get_token();
		d = ((matfunc_str)(functions[i].f))(token);
		*hold = d;
		get_token();
		if (save_code)
			code = save_code;
		return;
	}

	//last = args = (double_list*)malloc(sizeof(double_list));
	//args->next = NULL;
	//level1(&args->val);
	//get_token();
	argc=0;
	do 
	{
		get_token();
		if (*token == ')')
			break;
		t = (double_list*)allocmem(sizeof(double_list));
		code = 0;
		level1(&t->val);
		t->code = code;
		t->next = NULL;
		if (last)
			last->next = t;
		else
			args = t;
		last = t;
		argc++;
	} while (*token == ',');

	code = save_code;

	if (argc != functions[i].args && functions[i].args >= 0)
	{
		serror(ERR_BADPARAM);
	}
	else
	{
		switch (functions[i].args)
		{
			case 0:
				d = ((matfunc0)(functions[i].f))();
				break;
			case 1:
				d = ((matfunc)(functions[i].f))(args->val);
				break;			
			case 2:
				d = ((matfunc2)(functions[i].f))(args->val,args->next->val);
				break;			
			case 3:
				d = ((matfunc3)(functions[i].f))(args->val,args->next->val,args->next->next->val);
				break;		
			case INF_ARGS:
				d = ((matfunc_inf)(functions[i].f))(args);
				break;
		}
	}

	t = args;
	while (t)
	{
		args = t->next;
		freemem(t);
		t = args;
	}
	
  *hold = d;
//  else
//    serror( ERR_OVERFLOW);

}
コード例 #15
0
ファイル: seascene.cpp プロジェクト: helihyv/Ghosts-Overboard
SeaScene::SeaScene(QObject *parent) :
    QGraphicsScene(parent)
{

    setItemPointersNull();

    paused_ = false;
    screenLitKeeper_.keepScreenLit(true);

    QSettings settings;

    //set background

    QPixmap waves (":/pix/meri.png");
    waves.scaled(20,20);
    setBackgroundBrush(QBrush(waves));

    //set random seed

    qsrand(QTime::currentTime().msec()+2);  //+2 to avoid setting it to 1



//Setup level sets

    QList<Level> levelList;
    Level level1(5,10);
    levelList.append(level1);
    Level level2(5,10,2,50);
    levelList.append(level2);
    Level level3(5,15,2,50);
    levelList.append(level3);
    Level level4(5,15,4,50);
    levelList.append(level4);
    Level level5(5,15,5,100);
    levelList.append(level5);

    Levelset set ("Original",levelList);
    availableLevelsets_.append(set);


    //Create another set of levels and place it in the available levelsets list
    levelList.clear();
    Level set2level1(8,15,4,50);
    levelList.append(set2level1);
    Level set2level2(8,20,4,50);
    levelList.append(set2level2);
    Level set2level3(8,20,5,80);
    levelList.append(set2level3);
    Level set2level4(8,20,6,120);
    levelList.append(set2level4);
    Level set2level5(8,25,8,150);
    levelList.append(set2level5);

    Levelset set2("Difficult",levelList);
    availableLevelsets_.append(set2);


    //Setup starting levelset

    QString levelname = settings.value("levelset","Original").toString();
    bool found = false;
    foreach (Levelset levelset, availableLevelsets_)
    {
        if (levelset.getName() == levelname)
        {
            levelset_ = levelset;
            found = true;
            break;
        }
    }

    if (!found)  //The last used level is not available
    {
        levelset_ = availableLevelsets_.value(0);
    }

    currentLevel_ = 0;

    totalScore_ = 0;



    connect(this,SIGNAL(allGhostsPicked()),this,SLOT(nextLevel()));

    pVibrateAction_ = new QAction(tr("Vibration effects"),this);
    pVibrateAction_->setCheckable(true);
    connect(pVibrateAction_,SIGNAL(toggled(bool)),this,SLOT(vibrationActivate(bool)));

    pVibrateAction_->setChecked(settings.value("vibration",false).toBool());


    pPauseAction_ = new QAction(tr("Pause"),this);
    pPauseAction_->setCheckable(true);
    connect(pPauseAction_,SIGNAL(toggled(bool)),this,SLOT(pause(bool)));


    deviceLockPollTimer_.setInterval(20*60);
    connect(&deviceLockPollTimer_,SIGNAL(timeout()),this,SLOT(pollDeviceLocked()));
    deviceLockPollTimer_.start();


    autopauseTimer.setSingleShot(true);
    autopauseTimer.setInterval(15*60*1000);
    connect(&autopauseTimer,SIGNAL(timeout()),this,SLOT(turnPauseOn()));


}
コード例 #16
0
ファイル: HDF5data.cpp プロジェクト: rsnemmen/Chombo
int test()
{
#ifdef CH_USE_HDF5

  int error;
  HDF5Handle testFile;

  CH_assert(!testFile.isOpen());

  error = testFile.open("data.h5", HDF5Handle::CREATE);
  if (error != 0)
    {
      if ( verbose )
        pout() << indent2 << "File creation failed "<<error<<endl;
      return error;
    }

  CH_assert(testFile.isOpen());

  Box domain(IntVect::Zero, 20*IntVect::Unit);

  DisjointBoxLayout plan1, plan2;
  {
    IntVectSet tags;

    IntVect center = 10*IntVect::Unit;

    setCircleTags(tags, 6, 1, center); //circle/sphere

    buildDisjointBoxLayout(plan1, tags, domain);

    tags.makeEmpty();

    setCircleTags(tags, 5, 2, center);

    buildDisjointBoxLayout(plan2, tags, domain);
  }
  if ( verbose )
  {
    pout() << "plan1: " << procID() << "...." << plan1 << endl;
    pout() << "plan2: " << procID() << "...." << plan2 << endl;
  }

  //test LayoutData<Real> specialization
  LayoutData<Real>  specialReal(plan1);


  LayoutData<Moment>   vlPlan(plan1);


  LevelData<BaseFab<int> > level1(plan1, 3, IntVect::Unit);

  LevelData<BaseFab<int> > level2;

  level2.define(level1);

  level2.define(plan2, 1);

  for (DataIterator i(level2.dataIterator()); i.ok(); ++i)
  {
    level2[i()].setVal(2);
  }

  level1.apply(values::setVal1);

  level2.apply(values::setVal2);

  HDF5HeaderData set1;
  Real dx=0.004;
  Box b1(IntVect(D_DECL6(1,2,1,1,2,1)), IntVect(D_DECL6(4,4,4,4,4,4)));
  Box b2(IntVect(D_DECL6(5,2,1,5,2,1)), IntVect(D_DECL6(12,4,4,12,4,4)));
  int currentStep = 2332;

  set1.m_string["name"] = "set1";
  set1.m_real["dx"] = dx;
  set1.m_int["currentStep"] = currentStep;
  set1.m_intvect["some intvect or other"] = b1.smallEnd();
  set1.m_box["b1"] = b1;
  set1.m_box["b2"] = b2;

  testFile.setGroupToLevel(1);

  error = write(testFile, plan1);
  if (error != 0)
    {
      if ( verbose )
        pout() << indent2 << "box write failed "<<error<<endl;
      return error;
    }

  error = write(testFile, level1, "level1 state vector");
  if (error != 0)
    {
      if ( verbose )
        pout() << indent2 << "BoxLayoutData 1 write failed "<<error<<endl;
      return error;
    }

  testFile.setGroupToLevel(2);

  error = write(testFile, plan2);
  if (error != 0)
    {
      if ( verbose )
        pout() << indent2 << "box2 write failed "<<error<<endl;
      return error;
    }

  error = write(testFile, level2, "level2 state vector");
  if (error != 0)
    {
      if ( verbose )
        pout() << indent2 << "BoxLayoutData 2 write failed "<<error<<endl;
      return error;
    }

  LevelData<FArrayBox> state(plan2, 3);

  state.apply(values::setVal3);
  testFile.setGroupToLevel(0);
  set1.writeToFile(testFile);

  error = write(testFile, plan2);
  if (error != 0)
    {
      if ( verbose )
        pout() << indent2 << "box2 write failed "<<error<<endl;
      return error;
    }

  testFile.setGroup("/");

  error = writeLevel(testFile, 0, state, 2, 1, 0.001, b2, 2);
  if (error != 0)
    {
      if ( verbose )
        pout() << indent2 << "BoxLayoutData 2 write failed "<<error<<endl;
      return error;
    }

  set1.writeToFile(testFile);
  set1.writeToFile(testFile);

  testFile.close();

 CH_assert(!testFile.isOpen());

  // test the utility functions ReadUGHDF5 and WriteUGHDF5

  WriteUGHDF5("UGIO.hdf5", plan2, state, domain);

  ReadUGHDF5("UGIO.hdf5", plan2, state, domain);
  //========================================================================
  //
  //  now, read this data back in
  //
  //========================================================================

  BoxLayoutData<BaseFab<int> > readlevel1, readlevel2;

  error = testFile.open("data.h5", HDF5Handle::OPEN_RDONLY);
  if (error != 0)
    {
      if ( verbose )
        pout() << indent2 << "File open failed "<<error<<endl;
      return error;
    }

  testFile.setGroupToLevel(2);
  Vector<Box> boxes;
  error = read(testFile, boxes);

  if (error != 0)
    {
      if ( verbose )
        pout() << indent2 << "box read failed "<<error<<endl;
      return error;
    }
  boxes.sort();
  Vector<int> assign;
  error = LoadBalance(assign, boxes);
  if (error != 0)
    {
      if ( verbose )
        pout() << indent2 << "BoxLayout LoadBalance failed "<<error<<endl;
      return error;
    }
  BoxLayout readplan2(boxes, assign);
  readplan2.close();
  error = read(testFile, readlevel2, "level2 state vector", readplan2);
  if (error != 0)
    {
      if ( verbose )
        pout() << indent2 << "BoxLayoutData<BaseFab<int>> read failed "<<error<<endl;
      return error;
    }

  testFile.setGroupToLevel(1);
  error = read(testFile, boxes);
  if (error != 0)
    {
      if ( verbose )
        pout() << indent2 << "box read failed "<<error<<endl;
      return error;
    }

  error = LoadBalance(assign, boxes);
  if (error != 0)
    {
      if ( verbose )
        pout() << indent2 << "BoxLayout LoadBalance failed "<<error<<endl;
      return error;
    }
  BoxLayout readplan1(boxes, assign);
  readplan1.close();
  if ( verbose )
  {
    pout() << "readplan1: " << procID() << "...." << readplan1 << endl;
    pout() << "readplan2: " << procID() << "...." << readplan2 << endl;
  }
  error = read(testFile, readlevel1, "level1 state vector", readplan1);
  if (error != 0)
    {
      if ( verbose )
        pout() << indent2 << "BoxLayoutData<BaseFab<int>> read failed "<<error<<endl;
      return error;
    }

  if ( verbose )
    pout() << plan1<<readplan1<<endl;

  // real test of IO, make sure the data is the same coming and going

  DataIterator l1  = level1.dataIterator();
  DataIterator rl1 = readlevel1.dataIterator();
  DataIterator l2  = level2.dataIterator();
  DataIterator rl2 = readlevel2.dataIterator();

  if (level1.boxLayout().size() != readlevel1.boxLayout().size())
    {
      if ( verbose )
        pout() << indent2 << "level1.size() != readl1.size() read failed "<<error<<endl;
      return 1;
    }
  if (level2.boxLayout().size() != readlevel2.boxLayout().size())
    {
      if ( verbose )
        pout() << indent2 << "level2.size() != readl2.size() read failed "<<error<<endl;
      return 1;
    }

  // we can assume that BoxLayout IO is tested in HDF5boxIO
  BaseFab<int>* before, *after;
  for (; l1.ok(); ++l1, ++rl1)
    {

      before = &(level1[l1()]); after = &(readlevel1[rl1()]);
      for (int c=0; c<before->nComp(); ++c)
        {
          for (BoxIterator it(level1.box(l1())); it.ok(); ++it)
            {
              if ((*before)(it(), c) != (*after)(it(), c))
                {
                  if ( verbose )
                    pout() << indent2 << "l1 != readl1 read failed "<<error<<endl;
                  return 2;
                }
            }
        }
    }

  for (; l2.ok(); ++l2, ++rl2)
    {

      before = &(level2[l2()]); after = &(readlevel2[rl2()]);
      for (int c=0; c<before->nComp(); ++c)
        {
          for (BoxIterator it(level2.box(l2())); it.ok(); ++it)
            {
              if ((*before)(it(), c) != (*after)(it(), c))
                {
                  if ( verbose )
                    pout() << indent2 << "level2 != readlevel2 read failed "<<error<<endl;
                  return 3;
                }
            }
        }
    }

  LevelData<FArrayBox> readState;
  Real dt, time;
  int refRatio;

  testFile.setGroup("/");

  error = readLevel(testFile, 0, readState, dx, dt, time, b2, refRatio);
  if (error != 0)
    {
      if ( verbose )
        pout() << indent2 << "readLevel failed "<<error<<endl;
      return error;
    }

#ifndef CH_MPI
  // OK, now try to read one FArrayBox at a time
  // problem with DataIterator and running the out-of-core in parallel, so
  // have to think about that for now  BVS.
  FArrayBox readFAB;
  Interval  interval(1,2);
  testFile.setGroup("/");
  int index=0;
  for (DataIterator dit(state.dataIterator()); dit.ok(); ++index,++dit)
        {
          FArrayBox& fab = state[dit()];
          readFArrayBox(testFile, readFAB, 0, index, interval);
          for (BoxIterator it(state.box(dit())) ; it.ok() ; ++it)
                {
                  if (readFAB(it(), 0) != fab(it(), 1))
                        {
                          if ( verbose )
                                pout() << indent2 << "state != after for out-of-core "<<error<<endl;
                          return 3;
                        }
                }
        }

#endif

  testFile.close();

 CH_assert(!testFile.isOpen());

#endif // CH_USE_HDF5

  return 0;
}
コード例 #17
0
/**
Inputs: 
none

Returns: the initialized World object ready to be played
*/
world makeGame(short int level, short int numPlayers,int score){
    
    world gameWorld;
    gameWorld.nProj = 0;
    gameWorld.projList = (projectile*)calloc(MAX_PROJECTILES,sizeof(projectile));
    gameWorld.currentTime = 0; 
    
    gameWorld.player1 = (ship*)malloc(sizeof(ship));
    gameWorld.player1->AI_routine = NULL;
    gameWorld.player1->x_pos = (WORLD_X_SIZE/8)*3;
    gameWorld.player1->y_pos = WORLD_Y_SIZE-15;    
    gameWorld.player1->x_accel = 0; 
    gameWorld.player1->y_accel = UP;   
    gameWorld.player1->isAlive = 1;
    gameWorld.player1->last_x = 0;
    gameWorld.player1->last_y = 0;
    gameWorld.player1->dimensionID = 8;
    gameWorld.player1->startTime = 0;
    gameWorld.player1->ID = RESERVED_PLAYER1_ID;
    gameWorld.player1->drawPixels =  drawDIM8;
    gameWorld.player1->erase = eraseDIM8;
    gameWorld.player1->drawID = collideDIM8;    
    gameWorld.player1->AI_routine = NULL;
    gameWorld.player1->health = MAX_HEALTH;
    gameWorld.player1->lastHit = 0;
    
    gameWorld.score = score;
    
    if(numPlayers == 1){
        gameWorld.player2 = NULL; 
    }
    else{
    gameWorld.player2 = (ship*)malloc(sizeof(ship));
    gameWorld.player2->AI_routine = NULL;
    gameWorld.player2->x_pos = (WORLD_X_SIZE/8)*5;
    gameWorld.player2->y_pos = WORLD_Y_SIZE-15;    
    gameWorld.player2->x_accel = 0; 
    gameWorld.player2->y_accel = UP;   
    gameWorld.player2->isAlive = 1;
    gameWorld.player2->last_x = 0;
    gameWorld.player2->last_y = 0;
    gameWorld.player2->dimensionID = 8;
    gameWorld.player2->startTime = 0;
    gameWorld.player2->ID = RESERVED_PLAYER2_ID;
    gameWorld.player2->drawPixels =  drawDIM7;
    gameWorld.player2->erase = eraseDIM7;
    gameWorld.player2->drawID = collideDIM7;    
    gameWorld.player2->AI_routine = NULL;
    gameWorld.player2->health = MAX_HEALTH;
    gameWorld.player2->lastHit = 0;
    }
    
    if(level == 1){
        return level1(gameWorld);
    }
    else if(level == 2){
        return level2(gameWorld);
    }
    else if(level == 3){
        return level3(gameWorld);
    }
    else{
        return level1(gameWorld);
    }
}
コード例 #18
0
ファイル: main.cpp プロジェクト: mgitlin/CS3113-Work
int main(int argc, char *argv[])
{
	SDL_Init(SDL_INIT_VIDEO);
	displayWindow = SDL_CreateWindow("Final Project", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_OPENGL);
	SDL_GLContext context = SDL_GL_CreateContext(displayWindow);
	SDL_GL_MakeCurrent(displayWindow, context);
#ifdef _WINDOWS
	glewInit();
#endif

	ShaderProgram* program = new ShaderProgram(RESOURCE_FOLDER"vertex_textured.glsl", RESOURCE_FOLDER"fragment_textured.glsl");

	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	glViewport(0, 0, 640, 480);

	Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 4096);

	Matrix modelMatrix;
	Matrix textMatrix;
	Matrix viewMatrix;
	Matrix projectionMatrix;
	projectionMatrix.setOrthoProjection(-10.0f, 10.0f, -7.5f, 7.5f, -1.0f, 1.0f);
	
	std::vector<Entity> entities;

	int lastWinner;

	// Load player sprites
	GLint paddleBlue = LoadTextureClamp(RESOURCE_FOLDER"assets\\paddleBlu.png");
	GLint paddleRed = LoadTextureClamp(RESOURCE_FOLDER"assets\\paddleRed.png");
	// Load item sprites
	GLint coinCopperSprite = LoadTextureClamp(RESOURCE_FOLDER"assets\\coinCopper.png");
	GLint coinSilverSprite = LoadTextureClamp(RESOURCE_FOLDER"assets\\coinSilver.png");
	GLint coinGoldSprite = LoadTextureClamp(RESOURCE_FOLDER"assets\\coinGold.png");
	GLint coinPlatinumSprite = LoadTextureClamp(RESOURCE_FOLDER"assets\\coinPlatinum.png");
	GLint starCopperSprite = LoadTextureClamp(RESOURCE_FOLDER"assets\\starCopper.png");
	GLint starSilverSprite = LoadTextureClamp(RESOURCE_FOLDER"assets\\starSilver.png");
	GLint starGoldSprite = LoadTextureClamp(RESOURCE_FOLDER"assets\\starGold.png");
	GLint starPlatinumSprite = LoadTextureClamp(RESOURCE_FOLDER"assets\\starPlatinum.png");
	// Load font
	GLuint fontSheet = LoadTextureClamp(RESOURCE_FOLDER"assets\\font1.png");
	// Load level bg
	GLint mainBG = LoadTextureRepeat(RESOURCE_FOLDER"assets\\bg_main.png");
	GLint levelBG = LoadTextureRepeat(RESOURCE_FOLDER"assets\\bg_level.png");
	GLint overBG = LoadTextureRepeat(RESOURCE_FOLDER"assets\\bg_over.png");

	// Load music
	Mix_Music *music1;
	music1 = Mix_LoadMUS(RESOURCE_FOLDER"assets\\Im Free.mp3");
	Mix_Music *music2;
	music2 = Mix_LoadMUS(RESOURCE_FOLDER"assets\\Lagrima.mp3");
	Mix_Music *music3;
	music3 = Mix_LoadMUS(RESOURCE_FOLDER"assets\\The Old Song.mp3");
	Mix_Music *music4;
	music4 = Mix_LoadMUS(RESOURCE_FOLDER"assets\\FASE.mp3");
	// Load sounds
	Mix_Chunk* itemHit;
	itemHit = Mix_LoadWAV(RESOURCE_FOLDER"hit.wav");
	Mix_Chunk* buttonPress;
	buttonPress = Mix_LoadWAV(RESOURCE_FOLDER"Menu Selection Click.wav");


	// Initialize players
	Entity playerBlue(ENTITY_PLAYER, paddleBlue, fontSheet, SDL_SCANCODE_A, SDL_SCANCODE_D, -5.0f);
	Entity playerRed(ENTITY_PLAYER, paddleRed, fontSheet, SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT, 5.0f);

	Entity coinCopper(ENTITY_ITEM, coinCopperSprite, fontSheet, 10, buttonPress);
	Entity coinSilver(ENTITY_ITEM, coinSilverSprite, fontSheet, 25, buttonPress);
	Entity coinGold(ENTITY_ITEM, coinGoldSprite, fontSheet, 50, buttonPress);
	Entity coinPlatinum(ENTITY_ITEM, coinPlatinumSprite, fontSheet, 100, buttonPress);
	Entity starCopper(ENTITY_ITEM, starCopperSprite, fontSheet, 100, buttonPress);
	Entity starSilver(ENTITY_ITEM, starSilverSprite, fontSheet, 250, buttonPress);
	Entity starGold(ENTITY_ITEM, starGoldSprite, fontSheet, 500, buttonPress);
	Entity starPlatinum(ENTITY_ITEM, starPlatinumSprite, fontSheet, 1000, buttonPress);

	entities.push_back(playerBlue);
	entities.push_back(playerRed);
	entities.push_back(coinCopper);
	entities.push_back(coinSilver);
	entities.push_back(coinGold);
	entities.push_back(coinPlatinum);
	entities.push_back(starCopper);
	entities.push_back(starSilver);
	entities.push_back(starGold);
	entities.push_back(starPlatinum);

	Level level1(LEVEL_FREEPLAY, fontSheet, levelBG, music3, entities);
	Level level2(LEVEL_CLOCKED, fontSheet, levelBG, music4, entities);
	Level level3(LEVEL_SCORED, fontSheet, levelBG, music1, entities);

	Mix_PlayMusic(music3, -1);

	SDL_Event event;
	bool done = false;
	while (!done) {
		while (SDL_PollEvent(&event)) {
			if (event.type == SDL_QUIT || event.type == SDL_WINDOWEVENT_CLOSE) {
				done = true;
			}
		}
		glClear(GL_COLOR_BUFFER_BIT);

		program->setModelMatrix(modelMatrix);
		program->setViewMatrix(viewMatrix);
		program->setProjectionMatrix(projectionMatrix);
		glUseProgram(program->programID);

		switch (state)
		{
		case MAIN_MENU:
			RenderBG(program, mainBG);
			if (keys[SDL_SCANCODE_1]) { // Press 1 to get into game level
				state = GAME_LEVEL_1;
				Mix_PlayChannel(-1, buttonPress, 0);
				Mix_PlayMusic(level1.getBgm(), -1);
			}
			if (keys[SDL_SCANCODE_2]) { // Press 2 to get into game level
				state = GAME_LEVEL_2;
				Mix_PlayChannel(-1, buttonPress, 0);
				Mix_PlayMusic(level2.getBgm(), -1);
			}
			if (keys[SDL_SCANCODE_3]) { // Press 3 to get into game level
				state = GAME_LEVEL_3;
				Mix_PlayChannel(-1, buttonPress, 0);
				Mix_PlayMusic(level3.getBgm(), -1);
			}
			if (keys[SDL_SCANCODE_ESCAPE]){
				done = true;
			}
			break;
		case GAME_LEVEL_1:
			if (!level1.isComplete()){
				level1.Update();
				level1.FixedUpdate();
				level1.Render(program);
				level1.RenderText(program);
			}
			else {
				lastWinner = level1.getWinner();
				state = MAIN_MENU;
				level1.reset();
				Mix_PlayMusic(music3, -1);
			}
			break;
		case GAME_LEVEL_2:
			if (!level2.isComplete()){
				level2.Update();
				level2.FixedUpdate();
				level2.Render(program);
				level2.RenderText(program);
			}
			else {
				lastWinner = level2.getWinner();
				state = GAME_OVER;
				level2.reset();
				Mix_PlayMusic(music3, -1);
			}
			break;
		case GAME_LEVEL_3:
			if (!level3.isComplete()){
				level3.Update();
				level3.FixedUpdate();
				level3.Render(program);
				level3.RenderText(program);
			}
			else {
				lastWinner = level3.getWinner();
				state = GAME_OVER;
				level3.reset();
				Mix_PlayMusic(music3, -1);
			}
			break;
		case GAME_OVER:
			RenderBG(program, overBG);
			program->setModelMatrix(textMatrix);
			textMatrix.identity();
			textMatrix.Translate(-7.5f, 0.0f, 0.0f);
			if (lastWinner == 0)
				DrawText(program, fontSheet, "Blue Player wins!", 1.0f, 0.005f);
			else if (lastWinner == 1)
				DrawText(program, fontSheet, "Red Player wins!", 1.0f, 0.005f);
			if (keys[SDL_SCANCODE_RETURN]) {
				level1.reset();
				level2.reset();
				level3.reset();
				state = MAIN_MENU;
				Mix_PlayChannel(-1, buttonPress, 0);
			}
			else if (keys[SDL_SCANCODE_ESCAPE]) {
				done = true;
			}
			break;
		}

		SDL_GL_SwapWindow(displayWindow);
	}

	SDL_Quit();
	return 0;
}