void PlaceholderLevel::Init()
{
    m_foreground = new Foreground();
    m_foreground->Init();

    AddObject(m_foreground);

    CreateTitleScreenObject();

    m_currentLevel = new Level();
    m_nextLevel = new Level();

    InitLevel(m_currentLevel);
    InitLevel(m_nextLevel);

    m_movingBackground = new MovingBackground();
    m_movingBackground->Init();

    AddObject(m_movingBackground);

    m_background = new Background();
    m_background->Init();

    AddObject(m_background);

    ResetLevelsPosition();

    // Testing particle systems:
    InitParticleSystem();
}
void PlaceholderLevel::GoBeneathTheSurface()
{
    // We need to generate new levels for the underworld and delete the old ones (surface world).
    delete m_currentLevel;
    delete m_nextLevel;

    m_currentLevel = new Level(true);
    m_nextLevel = new Level(true);

    m_mainCharacter->GoBeneathTheSurface();

    InitLevel(m_currentLevel);
    InitLevel(m_nextLevel);

    // HACKATHON!!!
    m_currentLevel->Translate(glm::vec4(POSITION_FIRST_SPAWN, m_currentLevel->GetLastPlatformYPosition() - m_nextLevel->GetFirstPlatformYPosition() - 26, 0, 0));
    m_nextLevel->Translate(glm::vec4(POSITION_TO_SPAWN, m_currentLevel->GetLastPlatformYPosition() - m_nextLevel->GetFirstPlatformYPosition(), 0, 0));

    //throw std::exception("The method or operation is not implemented.");

    m_switchMusic = true;

    // update particles color
    auto it = m_particleSystemList.begin();
    auto endit = m_particleSystemList.end();
    glm::vec4 newMinColor(0.5f, 1.0f, 0.0f, 0.1f);
    glm::vec4 newMaxColor(1.0f, 1.0f, 0.0f, 0.4f);
    for (; it != endit; ++it)
    {
        (*it)->SetColor(newMinColor, newMaxColor);
    }

}
void LevelManager::IncreaseLevel() {
	level_++;
	level_velocity_ += 0.1f;

	// recreate level
	InitLevel();
}
Example #4
0
bool T_Level::InsertLevel(T_Level &Livello)
{

	//byte *sprite;
	//Levelst1 *map;

	/*if(!map)
		map=new Levelst1[SPRITETOT];
		//delete [] map;

	if(!sprite)
		sprite=new byte[SPRITETOT];
		//delete [] sprite;
	  */
	//map=new Levelst1[SPRITETOT];
	//sprite=new byte[SPRITETOT];

	if(!map||!sprite){
		//return false;
		InitLevel();
	}

	for(int i=0;i<SPRITETOT;i++){
 		map[i].solid=Livello.map[i].solid;
		map[i].terran=Livello.map[i].terran;
	//}

	//for(int i=0;i<SPRITETOT;i++){
		sprite[i]=Livello.sprite[i];
	}

	return true;
}
Example #5
0
//glut键盘响应函数
void KeyDown(unsigned char key, int a, int b){
    switch (key){
    case VK_ESCAPE:     // Esc键退出程序
        exit(0);
    case 'l':
        glEnable(GL_LIGHTING);
        break;
    case 'k':
        glDisable(GL_LIGHTING);
        break;
    case VK_RETURN: //Enter键切换关卡
        if (maze.LevelPortal()!=0)
        {
            currentLevel += maze.LevelPortal();
            if (currentLevel>0 && currentLevel<=levelSum)
            {
                InitLevel(maze.LevelPortal());
                return;
            }
            else //否则,在第一关起点或最后一关终点按回车,退出程序
            {
                exit(0);
            }
        }
        break;
    default:
        break;
    }

    if (key>='0'&&key<='9')
    {
        items.PlaceItemHere(key);
    }
}
void LevelManager::NewGame() {
	current_lives_ = TOTAL_PLAYER_LIVES;
	level_ = 1;
	level_velocity_ = 0.5f;

	InitLevel();
}
Example #7
0
void CPlayerCharacter::SetInfo()
{
	printf_s("플레이할 캐릭터 별명을 입력하세요\n");
	std::string str_alias;
	getline(std::cin, str_alias);
	SetName(str_alias);

	//divide languages after project is done
	//printf_s("다음 중 플레이할 언어 입력하세요 \n"); 
	//printf_s("1) C  2) JAVA  3) Python \n");
	/*later about language
	1. input by number
	2. put language information by string just like now
	###more importantly### 
	3. divide problem set by number 
	4. create monsters by this input number*/
	//std::string str_language;
	//getline(std::cin, str_language);
	//SetLang(str_language);
	InitPosition();
	InitLevel();
	InitExp();
	InitHP();
	InitProblemCounter();
}
Example #8
0
int main( int argc, char **argv )
{
    glutInit( &argc, argv );
    InitGL();

    glutPassiveMotionFunc( MouseMove );
    glutMotionFunc( MouseMove );
    glutKeyboardFunc( KeyDown );
    glutTimerFunc( 15, Timer, 0 );
    glutDisplayFunc( Display );

    InitLevel();
    glutMainLoop();
    return 0;
}
Example #9
0
// enter shell state
void EnterShellState()
{
	// set up drawlists
	InitDrawlists();

	// create default font
	CreateDefaultFont();

	// clear the screen
	glClear(
		GL_COLOR_BUFFER_BIT
#ifdef ENABLE_DEPTH_TEST
		| GL_DEPTH_BUFFER_BIT
#endif
		);

	// show back buffer
	Platform::Present();

	// reset simulation timer
	sim_rate = float(SIMULATION_RATE);
	sim_step = 1.0f / sim_rate;
	sim_turn = 0;
	sim_fraction = 1.0f;

	// input binding
	InitInput(INPUT_CONFIG.c_str());

	// level configuration
	InitLevel("shell.xml");

	// create options overlay
	shellmenu.mActive = NULL;
	shellmenu.Push(&shellmenumainpage);
	Overlay *options = new Overlay(0xef286ca5 /* "options" */);
	Database::overlay.Put(0xef286ca5 /* "options" */, options);
	options->SetAction(Overlay::Action(RenderShellOptions));
	options->Show();

	// start audio
	Sound::Resume();

	// play the startup sound (HACK)
	PlaySoundCue(0x94326baa /* "startup" */);

	// set to runtime mode
	runtime = true;
}
Example #10
0
byte PlayALevel(byte map)
{
	int lastTime = 1;
	byte exitcode = 0;

	if (!InitLevel(map))
	{
		mapToGoTo = 255;
		return LEVEL_ABORT;
	}

	exitcode = LEVEL_PLAYING;
	gameMode = GAMEMODE_PLAY;
	CDMessingTime = 0;
	garbageTime = 0;

	UpdateGuys(curMap, &curWorld); // this will force the camera into the right position
	// it also makes everybody animate by one frame, but no one will
	// ever notice
	while (exitcode == LEVEL_PLAYING)
	{
		lastTime += TimeLength() - CDMessingTime;
		StartClock();
		if (gameMode == GAMEMODE_PLAY)
			HandleKeyPresses();
		exitcode = LunaticRun(&lastTime);
		LunaticDraw();

		if (lastKey == 27 && gameMode == GAMEMODE_PLAY)
		{
			InitPauseMenu();
			gameMode = GAMEMODE_MENU;
		}

		if (!gamemgl->Process())
		{
			exitcode = LEVEL_ABORT;
			mapToGoTo = 255;
		}
		EndClock();
	}

	ExitLevel();
	return exitcode;
}
LTBOOL CMusic::RestoreMusicState(const CMusicState & newState)
{
    if (!IsInitialized()) return LTFALSE;

	// See if the new state is valid...

	if (!strlen(newState.szDirectory) || !strlen(newState.szControlFile))
	{
		return LTFALSE;
	}

	// See if anything has changed...

	if ((stricmp(m_State.szDirectory, newState.szDirectory) != 0) ||
		(stricmp(m_State.szControlFile, newState.szControlFile) != 0))
	{
		if (!InitLevel((char*)newState.szDirectory, (char*)newState.szControlFile))
		{
            return LTFALSE;
		}
	}

    return LTTRUE;
}
void PlaceholderLevel::Update()
{
    if(m_mainCharacter->GetCharacterState() == GamePlayObject::Dead)
    {
        m_mainCharacter->SetCharacterState(GamePlayObject::Falling);
    }
    if(m_mainCharacter->GetCharacterState() != GamePlayObject::WallStop)
    {
        m_background->Move();
        m_movingBackground->Move();
        m_foreground->Move();

        m_currentLevel->Translate(glm::vec4(SCROLLING_DISTANCE_PER_FRAME, 0, 0, 0));
        m_nextLevel->Translate(glm::vec4(SCROLLING_DISTANCE_PER_FRAME, 0, 0, 0));

        // Needs to generate a new level if the current one is getting out of the screen.
        if (m_currentLevel->GetPosition().x < POSITION_TO_DELETE)
        {
            // Are we currently beneath the surface?
            bool isBeneath = m_currentLevel->IsUnderGround();
            Level* levelToDel = m_currentLevel;
            m_currentLevel = m_nextLevel;
            delete levelToDel;

            m_nextLevel = new Level(isBeneath);
            InitLevel(m_nextLevel);
            m_nextLevel->Translate(glm::vec4(POSITION_TO_SPAWN, m_currentLevel->GetLastPlatformYPosition() - m_nextLevel->GetFirstPlatformYPosition(), 0, 0));
        }
    }

    // Might have to switch level if we fall down
    if (m_mainCharacter->GetPosition().y < SURFACE_HEIGHT_POSITION && m_currentLevel->IsUnderGround() == false)
    {
        GoBeneathTheSurface();
    }

    if (m_mainCharacter->GetPosition().y < DEATH_HEIGHT)
    {
        delete m_currentLevel;
        delete m_nextLevel;
        m_mainCharacter->SetCharacterState(GamePlayObject::Dead);

        m_mainCharacter->Reset();

        // reset level - HOLY COW SO MUCH HAAAAAAAAXXXXX
        m_currentLevel = new Level();
        m_nextLevel = new Level();

        InitLevel(m_currentLevel);
        InitLevel(m_nextLevel);

        ResetLevelsPosition();

        // Reset PArticle Colors
        auto it = m_particleSystemList.begin();
        auto endit = m_particleSystemList.end();
        glm::vec4 newMinColor(0.0f, 0.44f, 0.86f, 0.1f);
        glm::vec4 newMaxColor(1.0f, 1.0f, 1.0f, 0.4f);
        for (; it != endit; ++it)
        {
            (*it)->SetColor(newMinColor, newMaxColor);
        }

        SceneManager::GetInstance().SetCurrentScene(1); // GameOver Screen (so testsceneloader can manage space on screen)
    }

    if(m_switchMusic)
    {
        m_switchMusic = SoundManager::GetInstance().IncrementSwitchMusic(SoundManager::AboveToBelow);
    }

    // Calls the update on base class for updating all objects
    Scene::Update();
}
int pacman_exec( int fdfb, int fdrc, int fdlcd, char *cfgfile )
{
	struct timeval	tv;
	int				x;
	int				jumplevel=-1;

	if ( FBInitialize( 720, 576, 8, fdfb ) < 0 )
		return -1;

	setup_colors();

	if ( RcInitialize( fdrc ) < 0 )
		return -1;

	InitLevel( 0 );

	while( doexit != 3 )
	{
		MazeInitialize();
		DrawMaze( );	/* 0 = all */
		DrawFill();
		DrawGhosts( );
		DrawPac( );
		MazePig();

		doexit=0;
		while( !doexit )
		{
			tv.tv_sec = 0;
#ifdef HAVE_DREAMBOX_HARDWARE
			tv.tv_usec = 8000;
#else
			tv.tv_usec = 1000;
#endif
			x = select( 0, 0, 0, 0, &tv );		/* 10ms pause */
	
			MovePac( );
			MoveGhosts( );
			DrawGhosts( );
			DrawPac( );
#if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
			FBFlushGrafic();
#endif
			RcGetActCode( );
			CheckGhosts( );
		}

		if ( doexit != 3 )
		{
			actcode=0xee;
			if ( score )
				DrawScore();
			if ( !gametime )
				DrawGameOver();
#if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
			FBFlushGrafic();
#endif
			doexit=0;
			jumplevel=-1;
			while(( actcode != RC_OK ) && !doexit )
			{
				tv.tv_sec = 0;
				tv.tv_usec = 100000;
				x = select( 0, 0, 0, 0, &tv );		/* 100ms pause */
				RcGetActCode( );
				if ( actcode == RC_HELP )
				{
					while( realcode != 0xee )
						RcGetActCode( );
					actcode=0xee;
					while(( actcode == 0xee ) && !doexit )
					{
						tv.tv_sec = 0;
						tv.tv_usec = 100000;
						x = select( 0, 0, 0, 0, &tv );		/* 100ms pause */
						RcGetActCode( );
					}
					if ( actcode <= RC_9 )
					{
						jumplevel=actcode;
						actcode=RC_OK;
					}
				}
			}
			if ( gametime )
				NextLevel();
			else
				InitLevel( jumplevel );
		}
	}

	Fx2StopPig();

/* fx2 */
/* buffer leeren, damit neutrino nicht rumspinnt */
	realcode = RC_0;
	while( realcode != 0xee )
	{
		tv.tv_sec = 0;
		tv.tv_usec = 300000;
		x = select( 0, 0, 0, 0, &tv );		/* 300ms pause */
		RcGetActCode( );
	}

	RcClose();
	FBClose();

	return 0;
}
Example #14
0
// *EXPORT* On Level Load -- Run once as a level is loaded (including title screen level)
int OnLvlLoad() {

	// Restore some code the hook overwrote
	*(DWORD*)0x00B25958 = 0;
    
    ResetLunaModule();

    // WIP
    // dumpTypeLibrary((IDispatch*)*(DWORD*)0xB2D7E8, std::wcout);

    
    std::string custPath = WStr2Str(getCustomFolderPath());
    std::string wldPath = WStr2Str(GM_FULLDIR);
    std::string SndRoot = MusicManager::SndRoot();
    replaceSubStr(wldPath, "\"", "");
    replaceSubStr(wldPath, "\\\\", "\\");
    replaceSubStr(wldPath, "/", "\\");

    replaceSubStr(SndRoot, "\"", "");
    replaceSubStr(SndRoot, "\\\\", "\\");
    replaceSubStr(SndRoot, "/", "\\");

    bool doSoundLoading = false;

    if ((!custPath.empty()) && (file_existsX(custPath + "\\sounds.ini"))) {
        //If custom-level specific sounds.ini detected
        doSoundLoading = true;
        LevelCustomSounds = true;
    }
    else if (LevelCustomSounds) {
        //If custom-level specific sounds.ini was NOT detected, but was loaded recently - reload episode specific sounds
        doSoundLoading = true;
        LevelCustomSounds = false;
    }

    if (!episodeStarted) {
        //Load custom sounds if episode is not finally started
        if (wldPath != SndRoot) doSoundLoading = true;
    }

    if (doSoundLoading) MusicManager::loadCustomSounds(wldPath + "\\", custPath);
//	BMPBox::initMovieCache();
	if(gLunaEnabled) {
		// Load autocode
		gAutoMan.Clear(false);		
		gAutoMan.ReadFile((std::wstring)GM_FULLDIR);

		// Try to load world codes		
		gAutoMan.ReadWorld((std::wstring)GM_FULLDIR);

		// Init var bank
		gSavedVarBank.TryLoadWorldVars();
		gSavedVarBank.CheckSaveDeletion();
		gSavedVarBank.CopyBank(&gAutoMan.m_UserVars);

        //  Don't try to call the CLunaLua constructor... It's already
        //  constructed automatically once, and trying to do this will call
        //  the constructor extra times *without* ever calling the destructor,
        //  which can result in a memory leak of the whole Lua state!
		//    gLunaLua = CLunaLua();
		gLunaLua.init(CLunaLua::LUNALUA_LEVEL, (std::wstring)GM_FULLDIR, Level::GetName());
        gLunaLua.setReady(true);

		// Do some stuff
		gAutoMan.DoEvents(true); // do with init

		// Init some stuff
		InitLevel();	
		gAutoMan.m_Hearts = 2;	

		// Recount deaths
		gDeathCounter.Recount();
	}

    //PGE DBG STUFF
    //readAndWriteNPCSettings();
    //overwriteFunc();

	return 0;
}