Example #1
0
void TestState::update()
{
	if (TheGame::Instance().gameOver())
	{
		// Reset level and player stats
		TheGame::Instance().clearStats();
		loadLevel(m_levelFile);
		TheGame::Instance().setGameOver(false);
	}
	if (TheGame::Instance().resurrected())
	{
		// Reload level and reset player resurrected flag
		loadLevel(m_levelFile);
		TheGame::Instance().setResurrected(false);
		// Reset keys to zero
		TheGame::Instance().clearKeys();
	}
	else if (TheGame::Instance().levelCompleted())
	{
		// Put level completed and checkPoint flags as false
		TheGame::Instance().setLevelCompleted(false);
		TheGame::Instance().clearStats();
		// Start level from the beginning
		loadLevel(m_levelFile);
	}
	else
	{
		m_pLevel->update();
	}
}
Example #2
0
bool Game::nextLevel(){
    closeLevel();

    if(loadLevel(currentLevel++)){ //jesli znaleziono kolejny poziom
        showTitleText(QString("Gratulacje, przeszedles poziom ") +  QString::number(currentLevel-1));
        return true;
    }else{ //w przeciwnym razie ustawia poziom na zerowy
        loadLevel((this->currentLevel = 0)++);
        showTitleText(QString("Gratulacje, przeszedles cala gre !"));
    }
    return false;
}
Example #3
0
/* Function: initialize
 * Parameters: none
 * Reads list of levels into levels array, loads the first level,
 * sets up some OpenGL parameters */
void initialize() {
	FILE* handle;

	/* Seed random number generator */
	srand( (unsigned)time( NULL ) );

	/* Read level list */
	handle = fopen("levels.dat", "r");
	if (handle == NULL) {
		printf("Could not open board data file: levels.dat\n");
		exit(1);
	}
	while (!feof(handle)) {
		fscanf(handle, "%s", &levels[numLevels++]);
		if (numLevels == 32) break;		/* only load 32 levels */
	}
	fclose(handle);

	/* Load 1st level */
	loadLevel(levels[level]);

	/* Setup OpenGL */
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(45, windowWidth / windowHeight, 3, -3);
	glMatrixMode(GL_MODELVIEW);

	glClearColor(0.0, 0.0, 0.0, 0.0);
	glPointSize(2.0);
}
Example #4
0
void LevelManager::prevLevel() {
	if (mCurrentLevel != mLevels.size() + 1) {
		std::cout << "Changing to previous level" << std::endl;
		mCurrentLevel--;
		loadLevel(mCurrentLevel);
	}
}
//Load the Game from a save file
void Game::loadGame()
{
	std::string line;
	std::ifstream file;
	file.open(SAVE_FILE, std::ios::in);
	
	mLevel = 0;
	if (file.is_open())
	{
		//the last level passed by user is on the last line of the file
		int currLevel = 0;
		while (std::getline(file, line))
		{
			std::string::size_type sz; 
			//increase the level from the file with 1 to get the next level for user
			currLevel = std::stoi(line, &sz) + 1;
		}
		file.close();

		if (currLevel > MAX_LEVEL)
		{
			mLevel = 0;
		}
		else
		{
			mLevel = currLevel;
		}
	}

	//load data level from file
	loadLevel();
}
Example #6
0
StateLevel::StateLevel()
{
	loadLevel(o_gameObjects, i_levelNumber);

	Gplayer = &o_player;

	///////// LEVEL SET UP
	setUpLevel( o_gameObjects );

	o_player.die(o_gameObjects);

	if ( maxRoomX < 0 ){ maxRoomX = 100;}
	if ( maxRoomY < 0 ) maxRoomY = 100;

	std::ofstream data ("data/levels/score.lvl");

	data.clear();

	for ( int n = 0; n < (signed)o_scores.size(); n++ )
	{
		data << o_scores[n]->i_number << " " << o_scores[n]->b_unlocked << " " << o_scores[n]->i_highScore << " " << o_scores[n]->i_B << " " << o_scores[n]->i_S << " " << o_scores[n]->i_G << "\n";
	}

	b_go = false;
	b_restart = false;


}
Example #7
0
/******************************************************************************
 * Function:        void UserInit(void)
 *
 * PreCondition:    None
 *
 * Input:           None
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        This routine should take care of all of the demo code
 *                  initialization that is required.
 *
 * Note:            
 *
 *****************************************************************************/
void UserInit(void)
{
    //Make sure that the SD-card is not selected
    TRISCbits.TRISC6 = 0;
    LATCbits.LATC6 = 1;
    PORTCbits.RC6 = 1;

	/* Initialize the mTouch library */
	mTouchInit();

	/* Call the mTouch callibration function */
	mTouchCalibrate();

	/* Initialize the accelerometer */
	InitBma150(); 

    //make sure that the accelerometer is not selected
    LATCbits.LATC7 = 1;
    PORTCbits.RC7 = 1;

	Fill(0x00);
	g_level = 0;
	loadLevel(g_level);
	InitPhysics();
}//end UserInit
bool LevelEditor::loadLevelToEditor(const std::string& path){
	m_Level = loadLevel(path,true,NULL,NULL);
	if(m_Level){
		m_NameBox->setString(m_Level->getName());
		std::vector<Tile*>* tiles = m_Level->getTiles();
		for(int i = 0;i < tiles->size();i++){
			if(ContainsFlags((*tiles)[i]->getTileTypes(),GruntStart)){
				m_ObjectSprites->push_back(
				SpriteManager::instance()->createSprite((*tiles)[i],"PathGuy.png",1));
			}
			else if(ContainsFlags((*tiles)[i]->getTileTypes(),TeleStart)){
				m_ObjectSprites->push_back(
				SpriteManager::instance()->createSprite((*tiles)[i],"PathGuy.png",1));
			}
			else if(ContainsFlags((*tiles)[i]->getTileTypes(),GlobStart)){
				m_ObjectSprites->push_back(
				SpriteManager::instance()->createSprite((*tiles)[i],"PathGuy.png",1));
			}
			else if(ContainsFlags((*tiles)[i]->getTileTypes(),MotherStart)){
				m_ObjectSprites->push_back(
				SpriteManager::instance()->createSprite((*tiles)[i],"PathGuy.png",1));
			}
			else if(ContainsFlags((*tiles)[i]->getTileTypes(),PistolEnemy)){
				m_ObjectSprites->push_back(
				SpriteManager::instance()->createSprite((*tiles)[i],"TestEnemy.png",1));
			}
		}
		return true;
	}
	return false;
}
Example #9
0
void Widget::on_btnFinish_clicked()
{
    QMessageBox res;
    res.setText("Ваш результат: "+QString::number(getResult())+"% \n\n");
    res.setStandardButtons(QMessageBox::Ok);
    res.setDefaultButton(QMessageBox::Ok);
    res.exec();
    current_level++;

    int theme = ui->listWidget->currentRow();
    QString str =  ui->listWidget->item(theme)->text();
    int val = ui->sldDificult->value();

    if(current_level >= levels->value(str)->value(QString::number(val))->size())
    {
        QMessageBox msg;
        msg.setText("Вы завершили эту тему!\nПоздравляем!\nПопробуйте другие темы :)");
        msg.setStandardButtons(QMessageBox::Ok);
        msg.setDefaultButton(QMessageBox::Ok);
        msg.exec();
        ui->stackedWidget->setCurrentIndex(0);
    }
    else
    {
        loadLevel();
        ui->graphicsView_2->scene()->clear();
    }
}
Example #10
0
void Widget::on_btnStart_clicked()
{
    ui->stackedWidget->setCurrentIndex(2);
    current_level = 0;
    this->resizeEvent(NULL);
    loadLevel();
}
ModeMenu::ModeMenu() :
	mExitClicked(false),
	mLevelIndex(0)
{
	findLevels();
	loadLevel();
}
Example #12
0
StartRoom::StartRoom( QWidget *parent, const char *name)
    : QWidget( parent, name )
{
    QGridLayout *Form1Layout = new QGridLayout( this, 1, 1, 11, 6, "Form1Layout"); 
    QSpacerItem* spacer = new QSpacerItem( 20, 61, QSizePolicy::Minimum, QSizePolicy::Expanding );
    Form1Layout->addItem( spacer, 2, 1 );

    QHBoxLayout *layout1 = new QHBoxLayout( 0, 0, 6, "layout1"); 
    QSpacerItem* spacer_2 = new QSpacerItem( 91, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
    layout1->addItem( spacer_2 );

    picture = new QLabel( this, "picture" );
    layout1->addWidget( picture );
    QSpacerItem* spacer_3 = new QSpacerItem( 41, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
    layout1->addItem( spacer_3 );

    Form1Layout->addMultiCellLayout( layout1, 0, 0, 0, 1 );

    roomRange = new QSpinBox( this, "kcfg_StartingRoom" );
    roomRange->setMaxValue( 25 );
    roomRange->setMinValue( 1 );

    Form1Layout->addWidget( roomRange, 1, 1 );

    QLabel *textLabel = new QLabel( this, "textLabel" );
    textLabel->setText(i18n("First level:"));
    Form1Layout->addWidget( textLabel, 1, 0 );

    connect( roomRange, SIGNAL(valueChanged(int)), SLOT(loadLevel(int)));
    loadLevel(1);
}
Example #13
0
/*************************************************
* NEXT LEVEL
* DESCRIPTION: Advance the game to the next level.
**************************************************/
uint8_t NextLevel(struct MovingSolid* ball, struct Solid* paddle, struct Solid* solids, uint8_t* balls, uint16_t* num_blocks, uint16_t *ballSpeed, uint8_t level)
{
    display_solid(paddle, 1);
    display_moving_solid(ball, 1);
    *balls = 4;
    *ballSpeed = BALL_SPEED;
     printf_setFont_location(5, 300);
     _printf("Ball %d", *balls);
    build_solid(paddle, 200, 160, 5, 25, COLOR_RED);
    build_moving_solid(ball, 200, 167, 7, 7, COLOR_DRKGREY, SOLID_AUTOUP | SOLID_AUTOLEFT, 4);
    if (level < LEVELS)
    {
        level++;
    }
    else
    {
        level = 1;
    }
#if READ_EEPROMLEVEL == 1
	SetClockSpeed(0); //Clock Speed must be < 10Mhz to support EEProm
	 __disable_interrupt();
    EEProm_Write(BRICK_BREAKER_LEVEL, level); //Save the current level
    __enable_interrupt();
    SetClockSpeed(5); //Clock Speed must be < 10Mhz to support EEProm
#endif
    *num_blocks = loadLevel(solids, level);
    StartTimer(0, PADDLE_SPEED);
    StartTimer(1, *ballSpeed);
    StartTimer(2, SCORE_UPDATE);

    return level;
}
TransIcelandicExpress::TransIcelandicExpress() {
	// constructor
	music = NULL;
	angle = 0.0;
	dot_init = false;

	sgSetVec3( cameraPos, 0.0f, 0.013f, -0.2f );

	sgSetVec4( light_pos, -1.0f, -1.0f, -1.0f, 0.0f );

	sgSetVec4( light_amb,  0.2f, 0.2f, 0.3f, 1.0f );
	sgSetVec4( light_diff, 1.0f, 1.0f, 0.8f, 1.0f );
	sgSetVec4( light_spec, 1.0f, 1.0f, 1.0f, 1.0f );

	sgSetVec4( ocean_diff, 0.4f, 0.5f, 0.7f, 1.0f );

	player = new Player();

	showHelp = true;

	roadX = 0;
	roadY = 0;

	loadLevel( "./gamedata/levels/tess2.txt" );
	//loadLevel( "./gamedata/levels/SimpleRoad.txt" );
	//loadLevel( "./gamedata/levels/Challenge2.txt" );
}
Example #15
0
void SideScroller::renderGameLevel() {
	loadLevel();

	glClearColor(0.3f, 0.6f, 0.9f, 1.0f);
	glClear(GL_COLOR_BUFFER_BIT);

	// setting limits on view
	float xloc = -entities[0]->x;
	float yloc = -entities[0]->y;

	if (yloc > 1.5){
		yloc = 1.5;
	}
	if (xloc > 8.0){
		xloc = 8.0;
	}
	if (xloc < -8.0){
		xloc = -8.0;
	}

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glTranslatef(xloc, yloc, 0.0f);

	// render level
	// render level
	glBindTexture(GL_TEXTURE_2D, layoutSpriteSheetTexture);
	glEnable(GL_TEXTURE_2D);

	glVertexPointer(2, GL_FLOAT, 0, vertexData.data());
	glEnableClientState(GL_VERTEX_ARRAY);

	glTexCoordPointer(2, GL_FLOAT, 0, texCoordData.data());
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);

	glEnable(GL_BLEND);

	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();

	glTranslatef(-TILE_SIZE* mapWidth / 2, TILE_SIZE* mapHeight / 2, 0.0f);

	glDrawArrays(GL_QUADS, 0, vertexData.size() / 2);

	glDisable(GL_TEXTURE_2D);
	glPopMatrix();

	glDrawArrays(GL_QUADS, 0, vertexData.size() / 2);

	glDisable(GL_TEXTURE_2D);
	glDisable(GL_BLEND);
	glPopMatrix();

	// render entities
	for (size_t i = 0; i < entities.size(); i++) {
		entities[i]->Render();
	}
}
Example #16
0
int winLevel(lua_State *L) {
	danmakux.currentLevel++;
	std::stringstream levelno;
	levelno << danmakux.currentLevel;
	std::string level = "level" + levelno.str();
	loadLevel(level);
	return 0;
}
Example #17
0
nodachi2D::nodachi2D()
{
    initializePhysics();
    loadLevel();

    intitializeRenderContext();
    initializeThreads();
}
Example #18
0
void MainWindow::connectActions()
{
    connect(m_loadLevelAct, SIGNAL(triggered()), this, SIGNAL(loadLevel()));
    //connect(m_startGameAct, SIGNAL(triggered()), this, SLOT(startGame()));
    //connect(m_stopGameAct, SIGNAL(triggered()), this, SLOT(stop));
    connect(m_resumeGameAct, SIGNAL(triggered()), this, SIGNAL(play()));
    connect(m_pauseGameAct, SIGNAL(triggered()), this, SIGNAL(pause()));
}
int c_reloadLevel(lua_State *L) {
	loadLevel();
	reloadArt();
	initGameLevel();
	game_ResetData();
	video_ResetData(); // already called by reloadArt()
	return 0;
}
Example #20
0
	void Game::reset()
	{
		m_level = 0;
		m_state = Game::LevelTransition;
		m_ship.resetLives();

		loadLevel();
	}
Example #21
0
SoSeparator* createScene(void)
{
  SoSeparator *root = new SoSeparator ;

  player.light=new SoPointLight;
  player.light->location.setValue(SbVec3f(0,5,0));
  player.light->intensity.setValue(1);
  root->addChild(player.light);

  SoDirectionalLight*dl1=new SoDirectionalLight;
  // -1 right, 1 left : -1 top, 1 bottom : -1 back, 1 front
  dl1->direction.setValue(SbVec3f(0, -1, -0.5));
  dl1->intensity.setValue(1);
  root->addChild(dl1);

  SoMaterial *mat2 = new SoMaterial ;
  mat2->diffuseColor.setValue(0.0,0.7,0.7) ;
  mat2->ambientColor.setValue(0.0,0.0,0.7) ;
  mat2->specularColor.setValue(0.0,1.0,0.0) ;
  root->addChild(mat2) ;
  SoDrawStyle * drawstyle2 = new SoDrawStyle;
  drawstyle2->style.setValue(SoDrawStyleElement::FILLED);

  root->addChild(drawstyle2);
  SoSeparator *ballSep=new SoSeparator;
  SoSphere *ball=new SoSphere;
  player.position=new SoTranslation;
  player.position->translation.setValue(SbVec3f(0,1.5,0));
  ball->radius.setValue(0.5);
  ballSep->addChild(player.position);
  ballSep->addChild(ball);
  root->addChild(ballSep);

  //FILLED, LINES, POINTS, INVISIBLE 
  SoDrawStyle * drawstyle = new SoDrawStyle;
  drawstyle->style.setValue(SoDrawStyleElement::FILLED);
  //drawstyle->style.setValue(SoDrawStyleElement::LINES);
  root->addChild(drawstyle);
  
  SoMaterial *mat = new SoMaterial ;
  mat->diffuseColor.setValue(0.7,0.7,0.0) ;
  mat->ambientColor.setValue(0.7,0.0,0.0) ;
  mat->specularColor.setValue(0.0,1.0,0.0) ;
  mat->shininess.setValue(1.0) ;
  root->addChild(mat) ;

  loadLevel(root);

  SoTimerSensor *ts=new SoTimerSensor(increment, (void*)0);
  ts->schedule();

  SoEventCallback*cb=new SoEventCallback;
  cb->addEventCallback(SoKeyboardEvent::getClassTypeId(), keyboardCB, NULL);
  root->addChild(cb);

  return root ;
}
Example #22
0
void DarkMoonEngine::startupNew() {
	_currentLevel = 4;
	_currentSub = 0;
	loadLevel(4, 0);
	_currentBlock = 171;
	_currentDirection = 2;
	setHandItem(0);
	EoBCoreEngine::startupNew();
}
Example #23
0
void MEngine::loadLevelIfRequested()
{
    M_PROFILE_SCOPE(MEngine::loadLevelIfRequested);
	if(m_requestedLevelToLoad == NULL)
		return;

	loadLevel(m_requestedLevelToLoad);
	SAFE_FREE(m_requestedLevelToLoad);
}
Example #24
0
/* reset game */
void reset() {
	reset_path_ptr();
	reset_undone_ptr();
	path_length = 0;
	undone_length = 0;
	playing = 1;
	replaying = 0;
	loadLevel(current_level);
}
void ModeMenu::clickNextLevel(Widget* /*widget*/)
{
	if(mLevels.size() > 0)
	{
		mLevelIndex++;
		mLevelIndex %= mLevels.size();
		loadLevel();
	}
}
Example #26
0
void Level::newLevel(int levelNum) {
	levelNo = levelNum;
	cellList = new vector<Cell*> ();
	enemies = new vector<Actor*> ();
	friendlies = new vector<Actor*> ();
	this->player = new Player();
	player->setScreen(this->screenWidth, this->screenHeight);
	loadLevel();
}
Example #27
0
void SelectLevel()
{
	unsigned char i, j;
	SCROLL_WHEEL_DIRECTION scrollDir;
	char buffer[32];
	oledPutROMString((ROM_STRING)"    SELECT  LEVEL    ",0,0);
	
	scrollDir = GetScrollDirection();

	if (scrollDir == SCROLL_UP)
	{
		if (g_menuSelected > 0)
			g_menuSelected --;
	}
	else if (scrollDir == SCROLL_DOWN)
	{
		if (g_menuSelected < (LEVELS-1))
			g_menuSelected ++;
	}	

	if ((g_menuSelected - firstLevel) == 3 && (firstLevel < (LEVELS-4)))
		firstLevel++;

	if ((g_menuSelected - firstLevel) == 0 && (firstLevel > 0))
		firstLevel--;

	j = 0;
	for (i = firstLevel; i < firstLevel+4; i++)
	{
		sprintf((char *)buffer, (const far rom char *)("       Level %d      "), i);

		if (g_menuSelected == i)
		{
			oledPutNegString((unsigned char *)buffer,j+2,0);
		}
		else
			oledPutString((unsigned char *)buffer,j+2,0);

		j++;
	}

	w1 = mTouchReadButton(3);
	if (w1 < 600)
	{
		DemoIntroState = 6;
		g_menuSelected = 1;
	}

	w1 = mTouchReadButton(0);
	if (w1 < 600)
	{
		DemoIntroState = 0xFF;
		g_level=g_menuSelected;
		loadLevel(g_level);
	}
}
void ModeMenu::clickPrevLevel(Widget* /*widget*/)
{
	if(mLevels.size() > 0)
	{
		mLevelIndex--;
		if(mLevelIndex < 0)
			mLevelIndex = mLevels.size() - 1;
		loadLevel();
	}
}
void GamePlay::levelFinish(float time) //!< level finish function
{


	if(inPlay == false) //!< if game is not inplay
	{
			finalScore = score + timeScore; //!< calculate final score
			finalScore = finalScore + (lives*50); //!<include remaining lives in score
			StringMessage[FinalScore] = "Press R to play again! Final Score: "+ std::to_string(finalScore); //!<update final score
			backgroundMusic.stop();
			gameOverSound.play();
	}
	if(player.getPos().getX() >= 2120 && level == 1 && inPlay == true) //!< if the player reaches the end
	{
	
		player.setVel(Vector2D(0.f,0.f)); //!< stop the player from moving
		_sleep(20);
		blocks.erase(blocks.begin(), blocks.end());
		loadLevel("levelTwo.txt");
		level = 2;
		npc.erase (npc.begin(),npc.end()); //!< erase the npc vector
		castleSprite.setPosition(2470.f, 320.f);
		player.setPos(Vector2D(450.f,460.f));
		mainView.setCenter(player.getPos().getX(), player.getPos().getY() - 150);

	}

	if(player.getPos().getX() >=2470 && level == 2 && inPlay == true)
	{
		message[4].setPosition(2250,250); //!< set position of message in correct location
		npc.erase (npc.begin(),npc.end()); //!< erase the npc vector
		inPlay = false;
		level = 1;
	}
	if(sf::Keyboard::isKeyPressed(sf::Keyboard::R) && inPlay == false) //!< if the player hits R
		{
			blocks.erase(blocks.begin(), blocks.end());
			inPlay = true; // change inplay to be true
			init();			// re initialise the game
		}
	
	if(lives == 0)
	{
		level = 1;
		message[4].setPosition(mainView.getCenter().x,250); //!< set position of message in correct location
		backgroundMusic.stop();
		gameOverSound.play();
		if(sf::Keyboard::isKeyPressed(sf::Keyboard::R)) //!< if the player hits R
		{
			inPlay = true; //!< change inplay to be true
			npc.erase (npc.begin(),npc.end()); //!< erase the npc vector
			init();			//!< re initialise the game
		}
	}
}
Example #30
0
	void Game::updateState(float timeDelta)
	{
		m_stateTime -= timeDelta;
		switch(m_state)
		{
			case WaitingForStart:
			case WaitingForRespawn:
				if (m_stateTime <= 0.f)
				{
					if (m_state == Game::WaitingForRespawn)
					{
						m_ship.resetPosition();
						m_ship.makeInvincible();
					}
					m_state = Game::Playing;
				}
				break;
			case LevelTransition:
				if (m_stateTime <= 0.f)
				{
					m_state = Game::WaitingForStart;
					m_stateTime = 1.f;
					m_level++;
					loadLevel();
				}
				break;
			case Playing:
				if (m_asteroids.size() == 0)
				{
					m_state = Game::LevelTransition;
					m_stateTime = 2.f;
				}
				break;
			case Dead:
				if (m_ship.lives() <= 0)
				{
					m_state = Game::GameOver;
				}
				else
				{
					m_ship.removeLive();
					m_state = Game::WaitingForRespawn;
					m_stateTime = 2.f;
				}
			case GameOver:
				if (m_window.getKeyState(Graphics::KEY_ENTER) == Graphics::KeyState::Press
					|| m_window.getKeyState(Graphics::KEY_KP_ENTER) == Graphics::KeyState::Press)
				{
					reset();
				}
			default:
				break;
		}
	}