Beispiel #1
0
void Game::draw(sf::RenderWindow* window)
{
	/*//if(playerLives==0)
	{ //
	*///}
	switch (state)
	{
		case(LEVEL_ONE):

			if(levelLoaded==false)
			{
				LoadLevel(window,"level.dat");
			}
			break;
		case(LEVEL_TWO):
			if(levelCleared==true)
			{
			clearLevel();
			levelLoaded=false;
			}
			if(levelLoaded==false)
			{
				LoadLevel(window,"levelTwo.dat");
				//levelLoaded=true;
				level2Cleared=true;
			}
		break;
		case(GAME_OVER):
			{
			endGame(window);
			printf("REACHED GAME OVER STAGE");
			}
	}

	GameWindow->Clear( sf::Color( 255, 255, 255 ) );
	GameWindow->Draw(backGroundSprite);

	Player1->draw();
	beetle->draw();

	for(vector<Block*>::iterator i= blockVec.begin();i!=blockVec.end();i++)//Iterator that goes through the vector of blocks
	{
		(*i)->draw();
	}
	for(vector<Gem*>::iterator i= gemVec.begin();i!=gemVec.end();i++)//Iterator that goes through the vector of GEMS
	{
		(*i)->draw();
	}

	exit->draw();

	headsUpDisplay();
	GameWindow->Display();
	return;//Initialise sprites and draw them.
}
Beispiel #2
0
//=================================================================================================
void SingleInsideLocation::Load(GameReader& f, bool local, LOCATION_TOKEN token)
{
	InsideLocation::Load(f, local, token);

	if(last_visit != -1)
		LoadLevel(f, local);
}
Beispiel #3
0
void Game::Load()
{
    player.Restart();
    FILE* fp = fopen("trappedld26save.data", "rb");
    if (fp != NULL)
    {
        fseek(fp, 7 * sizeof(unsigned), SEEK_SET);
        fread(&level, sizeof(unsigned), 1, fp);
        fread(&player.posx, sizeof(unsigned), 1, fp);
        fread(&player.posy, sizeof(unsigned), 1, fp);
        player.Repos();
        if (!LoadLevel(level))
        {
            fclose(fp);
            Reset();
            return;
        }
        for (unsigned i = 0; i < Switch::switches.size(); i++)
        {
            unsigned char n;
            fread(&n, sizeof(unsigned char), 1, fp);
            if (n > 0)
            {
                Switch::switches[i].Flip();
            }
        }


        fclose(fp);
    }

}
Beispiel #4
0
void Level::ReceiveMessage(UINT message, WPARAM wParam, LPARAM lParam) 
{
	switch (message) 
	{
	case CM_KEY:
		break;
	case CM_LEVEL_LOAD:
		LoadLevel(pWorld->Instance()->level);
		MessageQueue::Instance()->SendMessage(CM_LEVEL_LENGTH, levelLength, NULL);
		break;
	case CM_CHARACTER_MOVE_X_FROM_TO:
		if(physic_behavior.MoveXFromTo((Location*)wParam,(Location*)lParam,surfaces)==true)
			MessageQueue::Instance()->SendMessage(CM_CHARACTER_BUMPS_INTO, (int)physic_behavior.pSurfaceFinal, NULL);
		break;

	case CM_CHARACTER_FALL_Y_FROM_TO:
		if(physic_behavior.FallYFromTo((Location*)wParam,(Location*)lParam,surfaces)==false)
			MessageQueue::Instance()->SendMessage(CM_CHARACTER_IS_FALLING, NULL, NULL);
		else
			MessageQueue::Instance()->SendMessage(CM_CHARACTER_IS_STANDING, (int)physic_behavior.pOnSurfaceFinalFall,(int)currentLevel->pSlopes);
		break;

	case CM_CHARACTER_JUMP_Y_FROM_TO:
		if(physic_behavior.JumpYFromTo((Location*)wParam,(Location*)lParam,surfaces)==true)
			MessageQueue::Instance()->SendMessage(CM_CHARACTER_JUMPING_BUMPS_HEAD, (int)physic_behavior.pOnSurfaceFinalJump, NULL);
		break;
	case CM_GAME_START:
		levelView.StartGame();
		//MessageQueue::Instance()->SendMessage(CM_LEVEL_BEGIN, NULL, NULL);
		break;
	case CM_WINTERLEVEL_OPEN_BRIDGE:
		this->surfaces[0]->isSurfaceOfDeath = false;
		break;
	}
}
void CGameManager::NewGame(string levelstring, int mapint)
{	
	//LoadLevel(levelstring);

	m_bLoadingFromSave = false;
	CParticleManager::GetInstance()->Clear();
	
	CTileManager::GetInstance()->ShutDown();
	Reset();
	LoadLevel(levelstring);	

	LoadMap(mapint);
	
	m_nPhaseCount = 0;
	// Player 1 and his units
	m_nNewPlayerID = 0;

	LoadUnitsFromScript();

	if (m_vPlayers[1]->GetAI())
	{
		CHero* pHero = dynamic_cast<CHero*>(CGameManager::GetInstance()->GetChampion(1));

		pHero->SwapSpell(CAbilityManager::GetInstance()->GetAbility(SP_HEAL), 0);
		pHero->SwapSpell(CAbilityManager::GetInstance()->GetAbility(SP_RALLY), 1);
		pHero->SwapSpell(CAbilityManager::GetInstance()->GetAbility(SP_MAGIC), 2);
		pHero->SwapSpell(CAbilityManager::GetInstance()->GetAbility(SP_CLEAVE), 3);
	}

	CAIManager::GetInstance()->BeginMovement();
	if (CMultiplayerState::GetInstance()->GetNetworkSetup())
	{
		BeginNetworkGame(CSocketClient::GetInstance()->m_nNetworkPlayerID);
	}
	m_nCurrentPhase = GP_MOVE;
	
	if( levelstring == "level5" )
	{
		for( int x = 0; x < CTileManager::GetInstance()->GetNumRows(); x++ )
		{
			for( int y = 0; y < CTileManager::GetInstance()->GetNumColumns(); y++ )
			{
				int zzzzzzzzzzzz = rand() % 5 + 1;
				if( zzzzzzzzzzzz == 1 )
				{
					Vec2D tmp;
					tmp.nPosX = x;
					tmp.nPosY = y;
					CParticleManager::GetInstance()->LoadParticles(PT_ICEBOLT, TranslateToPixel(tmp));
				}
			}
		}
		CGameplayState::GetInstance()->SetVignette(_T("vignette_snow"));
	}	
	else
	{
		CGameplayState::GetInstance()->SetVignette(_T("vignette"));
	}
}
Beispiel #6
0
void Game::RestartLevel()
{
    player.Restart();
    if (!LoadLevel(level))
    {
        Reset();
    }
}
Beispiel #7
0
void CCampaign::LoadLevel(int lvlNumber)
{
	bool nextLevel = false;
	CGame game(GetRow(campaignFile, lvlNumber), &nextLevel, renderer, window, resolution[0], resolution[1], "devsave", lvlNumber);
	if (nextLevel)
	{
		LoadLevel(lvlNumber + 1);
	}
}
Beispiel #8
0
Level* LevelFactory::LoadNextLevel()
{
	if (IsLastLevel() == true)
	{
		return myCurrentLevel;
	}

	return LoadLevel(myCurrentID + 1, myCurrentDifficultyID);
}
bool GameInst::Start()
{
	m_Running = true;
	
	// Load the level
	LoadLevel();

	return true;
}
Beispiel #10
0
bool LevelLoader::LevelLoaded(const string filename)
{
	if (LoadLevel(filename) == true)
	{
		printf("Level (%s) loaded successfully\n", filename.c_str());
		return true;
	}
	return false;
}
Beispiel #11
0
void Server::Run()
{
	LoadLevel();

	// Start threads
	hThreads[0] = (HANDLE)_beginthreadex(NULL, 0, &Server::UpdatePtr, this, 0, NULL);
	hThreads[1] = (HANDLE)_beginthreadex(NULL, 0, &Server::InteractionPtr, this, 0, NULL);

	// Wait until the threads have finished execution
	WaitForMultipleObjects(NUM_THREADS, hThreads, TRUE, INFINITE);
}
void GameInst::Update(float a_dt)
{
	if(m_Running)
	{
		//update physworld
		/*m_tLeftPhysUpdate -= a_dt;
		if(m_tLeftPhysUpdate < 0)
		{
			m_tLeftPhysUpdate = PHYS_UPDATE_INTERVAL;
		}*/
		cpSpaceStep(m_pSpace, a_dt);

		//update player
		if(m_pCursor)
		{
			m_pPlayer->SetRedirectDir( VectorNormalise(m_pCursor->GetPosition() - m_pPlayer->GetPosition()) );
		}
		m_pPlayer->Update(a_dt);

		//update emitters (emitters update their individual laser chains)
		for (auto it = Emitters.begin(); it != Emitters.end();++it)
		{
			(*it)->Update(a_dt);
			(*it)->ParseCatchers(catcherPositions);
			
			if ((*it)->GetWon()) {
				if (!m_won) {
					m_winImage->SetPosition(sf::Vector2f(512-(float)m_winImageSource.getSize().x/2,386-(float)m_winImageSource.getSize().y/2));
					m_GUIMgr.AddWidget(m_winImage);
					//Widgets.push_back(winText);
					m_won = true;
				} else {
					m_winTimer += a_dt;
					if (m_winTimer > 3.0f) {
						m_winImage->SetPosition(sf::Vector2f(2048,2048));
						m_GUIMgr.RemoveWidget(m_winImage);
						m_won = false;
						m_winTimer = 0.0f;
						UnloadLevel();
						LoadLevel();
						return;
					}
				}
			}
		}
		
		//update blocks
		for (auto it = m_blocks.begin(); it != m_blocks.end();++it)
		{
			(*it)->Update(a_dt);
		}
	}
}
Beispiel #13
0
int main(int argc, char *argv[100]) {

	int j = 0;
	srand( (unsigned)time( NULL ) );

	InitCurses();
	CheckScreenSize();
	CreateWindows(29, 28, 1, 1);

	//If they specified a level to load
	if((argc > 1) && (strlen(argv[1]) > 1)) {
		argv[1][99] = '\0';
		LoadLevel(argv[1]);
		MainLoop();
	}
        
	//If not, display intro screen then use default levels
	else {
		//Show intro "movie"
		IntroScreen();

		j = 1;
		//They want to start at a level 1-9
		if(argc > 1)
			for(LevelNumber = '1'; LevelNumber <= '9'; LevelNumber++)
				if(LevelNumber == argv[1][0]) j = LevelNumber - '0';

		//Load 9 levels, 1 by 1, if you can beat all 9 levels in a row, you're awesome
		for(LevelNumber = j; LevelNumber < 10; LevelNumber++) {
                        LevelFile[strlen(LevelFile) - 6] = '0';
			LevelFile[strlen(LevelFile) - 5] = LevelNumber + '0';
			LoadLevel(LevelFile);
			Invincible = 0;			//Reset invincibility
			MainLoop();
		}

	}

	ExitProgram("Good bye!");
}
Beispiel #14
0
static glbsp_ret_e HandleLevel(void)
{
  superblock_t *seg_list;
  node_t *root_node;
  node_t *root_stale_node;
  subsec_t *root_sub;

  glbsp_ret_e ret;

  if (cur_comms->cancelled)
    return GLBSP_E_Cancelled;

  DisplaySetBarLimit(1, 1000);
  DisplaySetBar(1, 0);

  cur_comms->build_pos = 0;

  LoadLevel();

  InitBlockmap();

  // create initial segs
  seg_list = CreateSegs();

  root_stale_node = (num_stale_nodes == 0) ? NULL : 
      LookupStaleNode(num_stale_nodes - 1);

  // recursively create nodes
  ret = BuildNodes(seg_list, &root_node, &root_sub, 0, root_stale_node);
  FreeSuper(seg_list);

  if (ret == GLBSP_E_OK)
  {
    ClockwiseBspTree(root_node);

    PrintVerbose("Built %d NODES, %d SSECTORS, %d SEGS, %d VERTEXES\n",
        num_nodes, num_subsecs, num_segs, num_normal_vert + num_gl_vert);

    if (root_node)
      PrintVerbose("Heights of left and right subtrees = (%d,%d)\n",
          ComputeBspHeight(root_node->r.node),
          ComputeBspHeight(root_node->l.node));

    SaveLevel(root_node);
  }

  FreeLevel();
  FreeQuickAllocCuts();
  FreeQuickAllocSupers();

  return ret;
}
Beispiel #15
0
void DemoScreenCollisionLevelFile::Start()
{
	//Loads the file from Config\ActorDef\collisionlevel_demo.lvl
	LoadLevel("collisionlevel_demo");

	//All the magic happens in the level file!





	//Demo housekeeping below this point. 
	#pragma region Demo housekeeping
	t = new TextActor("Console", "These Actors were also placed using a level file.");
	t->SetPosition(0, 4.5);
	t->SetAlignment(TXT_Center);
	theWorld.Add(t, 10);
	t2 = new TextActor("Console", "Their physics-related properties came from actor definitions.");
	t2->SetPosition(0, -3.5);
	t2->SetAlignment(TXT_Center);
	theWorld.Add(t2, 10);
	t3 = new TextActor("Console", "They respond to sound in a data driven way.");
	t3->SetPosition(0, -4.5);
	t3->SetAlignment(TXT_Center);
	theWorld.Add(t3, 10);
	t4 = new TextActor("Console", "If the only collision response you need is sound, this is easier.");
	t4->SetPosition(0, -5.5);
	t4->SetAlignment(TXT_Center);
	theWorld.Add(t4, 10);
	TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenCollisionLevelFile.cpp, collisionlevel_demo.lvl,");
	TextActor *fileLoc2 = new TextActor("ConsoleSmall", "      ground_actor.adf, physics_event_actor.adf");
	fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 745));
	fileLoc->SetColor(.3f, .3f, .3f);
	fileLoc2->SetPosition(MathUtil::ScreenToWorld(5, 763));
	fileLoc2->SetColor(.3f, .3f, .3f);
	theWorld.Add(fileLoc, 10);
	theWorld.Add(fileLoc2, 10);
	_objects.push_back(fileLoc);
	_objects.push_back(fileLoc2);
	_objects.push_back(t);
	_objects.push_back(t2);
	_objects.push_back(t3);
	_objects.push_back(t4);
	ActorSet spawnedActors = tagList.GetObjectsTagged("spawned");
	ActorSet::iterator it = spawnedActors.begin();
	while (it != spawnedActors.end())
	{
		_objects.push_back(*it);
		it++;
	}
	#pragma endregion
}
Beispiel #16
0
void Editor::ButtonDown(std::string button) {
    if (button == "1") {
        state->CurrentState = "none";
    } else if (button == "2") {
        state->CurrentState = "terrain";
    }else if (button == "3") {
        state->CurrentState = "physics";
    } else if (button == " ") {
        SaveLevel("Level.txt");
    } else if (button == "l") {
        LoadLevel("Level.txt");
    }
}
void StateManager::NextLevel()
{
  levelCount++;
  if(levelCount < levels.size())
  {
    levelName = levels[levelCount];
    LoadLevel(levelName);
  }
  else
  {
    nextState = STATE_START;
    levelCount = -1;
  }
}
Beispiel #18
0
void CGameServer::LoadLevel(tstring sFile)
{
	CHandle<CLevel> pLevel = GetLevel(sFile);

	if (pLevel.expired())
		return;

	if (m_bRestartLevel)
		LoadLevel(pLevel);
	else
	{
		std::basic_ifstream<tchar> f(sFile.c_str());

		CData* pData = new CData();
		CDataSerializer::Read(f, pData);

		pLevel->CreateEntitiesFromData(pData);

		LoadLevel(pLevel);

		delete pData;
	}
}
//-----------------------------------------------------------------------------------------------------------------------------------
void RacetrackScreen::LoadContent()
{
  GameplayScreen::LoadContent();

  LoadLevel();

  // Always add player car first
  PlayerCar* playerCar = new PlayerCar(m_startingPositions.front(), PlayerData::GetInstance().GetCurrentCarAsset());
  AddPlayerCar(playerCar);

  //AddAICar(new AICar(m_startingPositions.front(), "Corvette.xml", m_trackPoints));
  
  ScreenManager::GetCamera().FocusOnPosition(playerCar->GetWorldPosition());
  GetScreenManager()->GetCamera().SetToFollowPosition(&playerCar->GetLocalPosition());
}
Beispiel #20
0
bool GameSession::LoadNew(const char *pTitle, std::shared_ptr<Track> track, char pGameOpts)
{
	bool lReturnValue = false;

	Clean();
	if (track) {
		mTitle = pTitle;
		this->track = track;
		lReturnValue = LoadLevel(pGameOpts);

		if(!lReturnValue)
			Clean();
	}

	return lReturnValue;
}
Beispiel #21
0
Level::Level( Game* OwningGame, char* FileName )
{
	Owner = OwningGame;
	MusicTracks = new List();
	Events = new List();
	Layers = new List();
	EnemyTemplates = new List();
	Scripts = new List();

	LayerCollisionIndex = -1;
	LayerGameIndex = -1;
	ScrollLevelPosition = 0;
	ScrollSpeedModifier = 1.0f;

	LoadLevel( FileName );
}
Beispiel #22
0
bool LevelLoader::NextLevel()
{
	// Move up our level count
	if(static_cast<unsigned int>(m_currentLevel + 1) > m_levelList.size())
		return false;

	++m_currentLevel;

	// Clear our world manager of current objects
	m_worldMan->CleanupEntities();

	// Load up entities from next level
	if(!LoadLevel(m_levelList[m_currentLevel]))
		return false;
	

	return true;
}
Beispiel #23
0
void Map::Load(const char* pLevelFile, const char* pTexturePack)
{
	//Clean up before we start loading anything
	Unload();

	// Load level data
	if(!LoadLevel(pLevelFile))
	{
		Unload();
		return;
	}

	// Load texture pack
	if(!LoadTexturePack(pTexturePack))
	{
		Unload();
		return;
	}
}
Beispiel #24
0
void Game::MainLoop()
{
    Init();
    event = new SDL_Event();
    LoadLevel();
    LoadTextures();
    while(!quitGame)
    {
        while(SDL_PollEvent(event) != 0)
        {
            SDL_RenderClear(renderer);
            Update();
            RenderTextures();
            SDL_RenderPresent(renderer);
        }
    }
    Close();

}
Beispiel #25
0
void CLevelManager::Process(Float32 _delta)
{
	if (0 != m_currLevel)
	{
		m_current->Process(_delta);

		FileParser::IParser* save = FileParser::LoadFile("data/xml/saveState.xml");
		assert(save);
		save->AddRef();

		if (m_current->IsComplete())
		{
			// save score from completed level
			Int32 score = 0;

			Int8 text[MAX_BUFFER];
			SDL_snprintf(text, MAX_BUFFER, "%iScore", m_currLevel);
			save->AddValue(text, m_current->GetScore());
			save->Save();

			++m_currLevel;

			if (m_currLevel <= m_numlevels)
			{
				Int8* temp = new Int8[MAX_BUFFER];
				SDL_snprintf(temp, MAX_BUFFER, "data/levels/%i.json", m_currLevel);
				if (!LoadLevel(temp))
				{
					Logger::Write("Failed to load level %s", temp);
				}
				CLEANARRAY(temp);
			}
			else
			{
				save->AddValue("currLevel", 1);
				m_currLevel = 1;
				m_finLevels = true;
			}
		}
		save->Release();
	}
}
Beispiel #26
0
Fleet::Fleet() {
	//Initialize all the variables
	fleet_matrix = new Matrix<Invader*>(FLEET_ROWS, FLEET_COLUMNS);
	
	for(short row = 0, column = 0; row != FLEET_ROWS; column++) {
			
			//Reset the columns when reached the limit of the matrix
			if(column == FLEET_COLUMNS) {
				column = -1;
				row++;
			} else {
				//Revive the Invader
				fleet_matrix->Set(row, column, new Invader());
			}
		}
	
	space_definition.h = (FLEET_ROWS * INVADER_SPRITE_DIMENSION);
	space_definition.w = (FLEET_COLUMNS * INVADER_SPRITE_DIMENSION) + ((FLEET_COLUMNS - 1) * INVADERS_SEPARATION);
	
	LoadLevel(1);
}
Beispiel #27
0
//---------------------------------------------------------------------------
void __fastcall TBookmarks::Load(THierarchicalStorage * Storage)
{
  for (int i = 0; i <= 3; i++)
  {
    if (Storage->OpenSubKey(Keys[i], false))
    {
      TStrings * BookmarkKeys = new TStringList();
      try
      {
        Storage->GetSubKeyNames(BookmarkKeys);
        for (int Index = 0; Index < BookmarkKeys->Count; Index++)
        {
          UnicodeString Key = BookmarkKeys->Strings[Index];
          if (Storage->OpenSubKey(Key, false))
          {
            TBookmarkList * BookmarkList = Bookmarks[Key];
            if (!BookmarkList)
            {
              BookmarkList = new TBookmarkList();
              FBookmarkLists->AddObject(Key, BookmarkList);
            }
            if (i < 3)
            {
              LoadLevel(Storage, L"", i, BookmarkList);
            }
            else
            {
              BookmarkList->LoadOptions(Storage);
            }
            Storage->CloseSubKey();
          }
        }
      }
      __finally
      {
        delete BookmarkKeys;
      }
      Storage->CloseSubKey();
    }
  }
Beispiel #28
0
level::level(int areaid , GameEngine* myengine)
{

  engine = myengine;

  LoadLevel( (char*) PALLET );
  /*Leagacy Code*/
  // int * mapdata;
  // int * lampmap;
  
  //   //get level data
  // level_in( areaid , mapdata, lampmap, levelx, levely);
  
  // //load pallet town tilest and store in level tileset var
  // loadMedia( (char*)PALLET /*tile_set_path[ areaid ]*/ , tileSet, engine->get_screen() );
  
  // LoadLevel( (char*)PALLET );
  
  // //mainmap = tilesetup(levelx , levely, mapdata,lampmap );
  // spritemap = spritesetup( levelx, levely , mainmap);
  

}
void ContinueHere()
{
bool GotoIntro = false;
bool ContinueWithThisLevel = false;
LevelHeight=1; SetLevelHeight(LevelHeight);
ClearLevel();
ReDrawScreen();
{Print (120,80,   " PLUS:      ");}
{Print (120,90,   "   Exit     ");}
{Print (120,108,  " OK:        ");}
{Print (120,118,  "   Continue ");}
SDL_UpdateRect(DisplaySurface,0,0,0,0);


    getInput();
    while(Key_ESCAPE_pressed == false && Key_ENTER_pressed == false)
	{
     getInput();
     if(Key_ESCAPE_pressed == true){GotoIntro = true;}
     if(Key_ENTER_pressed == true) {DrawGuidepoints=true;ContinueWithThisLevel = true;}
     }
if(GotoIntro == true)             {ClearLevel();intro();}
if(ContinueWithThisLevel == true) {LoadLevel(LevelNumber); game_singleplayer();}
}
Beispiel #30
0
bool GameInst::Start()
{
    m_Running = true;

    // Load the level
    LoadLevel();

    // Set up the laser sprites
    /*for (int i = 0; i < 1000; ++i) {
    	SpriteID laser;
    	m_ResMgr.CreateSprite("media/laser.png", &laser);
    	m_laserSprites.push_back(laser);
    }*/

    // Add them to the draw list (has to be separate for some reason)
    for (auto it = m_laserSprites.begin(); it != m_laserSprites.end(); ++it) {
        m_Renderer.AddDrawableSprite(&(*it));
    }

    //enable user input to the player
    m_pPlayer->SetInputHandler(m_pInputHandler);

    return true;
}