Example #1
0
bool UMediaPlayer::OpenUrl( const FString& NewUrl )
{
	URL = NewUrl;
	InitializePlayer();

	return (CurrentUrl == NewUrl);
}
Example #2
0
void Player::SetPlayer(ObjectCharacter* character)
{
  player = character;
  Interactions::Player::SetPlayer(character);
  InitializeInteractions();
  InitializeInventoryUi();
  InitializeMainBar();
  InitializePlayer();
}
Example #3
0
void UMediaPlayer::PostLoad()
{
	Super::PostLoad();

	if (!HasAnyFlags(RF_ClassDefaultObject) && !GIsBuildMachine)
	{
		InitializePlayer();
	}
}
void CSakiServerEngine::HandleStateGameOver()
{
	if (m_startEnding == 0)
	{
		m_startEnding = ::GetTickCount64();

		// Who is the winner?
		unsigned char winner = 0;
		for (auto x : m_players)
		{
			if (m_goners.find(x.first) == m_goners.end())
			{
				winner = x.first;
				break;
			}
		}

		// Notify the winner to everybody
		for (auto x : m_players)
		{
			auto msg = SakiSnakeCommon::Msg<SakiSnakeCommon::msgGameOver, SakiSnakeCommon::GameOverMsg>();
			msg._data._winner = winner;
			x.second->Send(&msg);
		}
	}
	else if (::GetTickCount64() - m_startEnding > 5000) // Reset game 5 seconds after the game over.
	{
		m_board.Clear();

		m_goners.clear();
		
		m_startEnding = 0;

		for (auto x : m_players)
		{
			InitializePlayer(x.second);
		}

		if (m_players.size() > 0 && m_players.size() < SakiSnakeCommon::maxPlayers)
		{
			m_state = stateAccepting;
		}
		else if (m_players.size() == SakiSnakeCommon::maxPlayers)
		{
			m_state = stateCountDown;
			m_startCounting = ::GetTickCount64();
		}
		else if (m_players.size() == 0)
		{
			m_state = stateNone;
		}

		BroadcastBoard();
	}
}
Example #5
0
    /// Initializes the gameplay state.
    /// @param[in]  screen_width_in_pixels - The width of the screen, in pixels.
    /// @param[in]  saved_game_data - The saved game data to use to initialize the gameplay state.
    /// @param[in,out]  overworld - The overworld for the gameplay state.
    /// @return True if initialization succeeded; false otherwise.
    bool GameplayState::Initialize(
        const unsigned int screen_width_in_pixels,
        const SavedGameData& saved_game_data,
        const std::shared_ptr<MAPS::Overworld>& overworld)
    {
        // MAKE SURE AN OVERWORLD WAS PROVIDED.
        bool overworld_exists = (nullptr != overworld);
        if (!overworld_exists)
        {
            // The gameplay state requires an overworld.
            return false;
        }

        // SET THE OVERWORLD.
        Overworld = overworld;

        // INITIALIZE THE PLAYER.
        std::unique_ptr<OBJECTS::Noah> noah_player = InitializePlayer(saved_game_data);
        bool player_initialized = (nullptr != noah_player);
        if (player_initialized)
        {
            Overworld->NoahPlayer = std::move(noah_player);
        }
        else
        {
            // The gameplay state requires a player.
            return false;
        }

        // INITIALIZE THE HUD.
        Hud = InitializeHud(screen_width_in_pixels, Overworld);
        bool hud_initialized = (nullptr != Hud);
        if (!hud_initialized)
        {
            // The gameplay state requires a HUD.
            return false;
        }

        // INITIALIZE THE BIBLE VERSES LEFT TO FIND.
        std::set_difference(
            BIBLE::BIBLE_VERSES.cbegin(),
            BIBLE::BIBLE_VERSES.cend(),
            saved_game_data.FoundBibleVerses.cbegin(),
            saved_game_data.FoundBibleVerses.cend(),
            std::inserter(BibleVersesLeftToFind, BibleVersesLeftToFind.begin()));

        // START PLAYING THE BACKGROUND MUSIC.
        Overworld->BackgroundMusic->play();
        
        // INDICATE WHETHER OR NOT INITIALIZATION SUCCEEDED.
        bool initialization_succeeded = hud_initialized;
        return initialization_succeeded;
    }
Example #6
0
void InitializeLevel(void)
{
	Vec3 TextTint;

	ResetObjectList();
	ResetCamera();

	// Initialize the player
	InitializePlayer(&CurrentPlayer, Mayple, 0, -220);
	CurrentPlayer.PlayerCollider.Position = CurrentPlayer.Position;

	Vec3Set(&TextTint, 1, 1, 1);
	LevelName = CreateText("Level 4", 0, 300, 100, TextTint, Center, Border);
	ChangeTextVisibility(LevelName);
}
Example #7
0
void Game::Run()
{
	XmlParser parser("settings/Players.xml");
	PlayerType playerType = (PlayerType)parser.ReadInt("/PlayerData/PlayerOneType");
	u32 keybinds[4] = { CL_KEY_LEFT, CL_KEY_RIGHT, CL_KEY_UP, CL_KEY_J };

	Initialize();
	InitializeLevel();	
	InitializePlayer(playerType, keybinds);

	s32 timeElapsedMs, lastTime, currentTime, waitTime;
	currentTime = lastTime = CL_System::get_time();

	// Main game loop
	while(!m_quit) {
		//Calculate the elapsed time since the beginning of the last frame
		currentTime = CL_System::get_time();
		timeElapsedMs = currentTime - lastTime;
		if (timeElapsedMs > 50)	{
			//Guard to ensure that the frame time isn't too long
			timeElapsedMs = 50;
		}
		lastTime = currentTime;
		
		//Update the game state
		m_level->Update();
		m_updateSignal.invoke(timeElapsedMs);	
		m_drawSignal.invoke();
		
		// Flip the display, showing on the screen what we drew since last call to flip()
		m_window.flip(0);

		//Measure the time for this frame's update
		waitTime = 16 - (CL_System::get_time() - currentTime);
		if (waitTime < 0) {
			waitTime = 0;
		}

		// This call processes user input and other events
		CL_KeepAlive::process(0);

		// Sleep for a little while to avoid using too much of the CPU.
		CL_System::sleep(waitTime);		
	}
}
CSakiPlayer* CSakiServerEngine::JoinGame(CAsyncSocket* pVisitor)
{
	CSakiPlayer* player = nullptr;
	unsigned char playerId = 0;

	for (int i = SakiSnakeCommon::player1; i <= SakiSnakeCommon::player4 && player == 0; i++)
	{
		if (m_players.find(i) == m_players.end())
		{
			playerId = i;
			player = new CSakiPlayer(playerId, pVisitor);
			m_players[playerId] = player;

			InitializePlayer(player);
		}
	}

	return player;
}
Example #9
0
BOOL InitializeModules()
{
    if (!InitializeScript())
        {
            return false;
        }

    if(!InitializeSyslog())
        {
            return false;
        }

    if (!InitializeOlc())
        {
            return false;
        }
    if (!InitializeOlcs())
        {
            return false;
        }

    if (!InitializeSocials())
        {
            return false;
        }

    InitializePlayer();

    if (!InitializeExternalModules())
        {
            return false;
        }
    if (!InitializeExternalExtensions())
        {
            return false;
        }

    return true;
}
Example #10
0
// Gameplay Screen Initialization logic
void InitGameplayScreen(void)
{
    // TODO: Initialize GAMEPLAY screen variables here!
    framesCounter = 0;
    finishScreen = 0;
    
    // MAP LAODING
        // TODO: Read .bmp file propierly in order to get image width & height
    Color *mapPixels = malloc(GRID_WIDTH*GRID_HEIGHT * sizeof(Color));
    mapPixels = GetImageData(LoadImage("assets/gameplay_screen/maps/map.bmp"));
    
    maxTriangles = 0;
    maxPlatforms = 0;
    
    for (int i=0; i<GRID_WIDTH*GRID_HEIGHT; i++)
    {
        /*
        printf("r: %i\n", mapPixels[i].r);
        printf("g: %i\n", mapPixels[i].g);
        printf("b: %i\n\n", mapPixels[i].b);
        */
        if (mapPixels[i].r == 255 && mapPixels[i].g == 0 && mapPixels[i].b == 0) maxTriangles++;
        else if (mapPixels[i].r == 0 && mapPixels[i].g == 255 && mapPixels[i].b == 0) maxPlatforms++;
    }
    
    triangles = malloc(maxTriangles * sizeof(TriangleObject));
    platforms = malloc(maxPlatforms * sizeof(SquareObject));
    
    int trianglesCounter=0;
    int platformsCounter=0;
    
    
    for (int y=0; y<GRID_HEIGHT; y++)
    {
        for (int x=0; x<GRID_WIDTH; x++)
        {
            if (mapPixels[y*GRID_WIDTH+x].r == 255 && mapPixels[y*GRID_WIDTH+x].g == 0 && mapPixels[y*GRID_WIDTH+x].b == 0) 
            {
                InitializeTriangle(&triangles[trianglesCounter], (Vector2){x, y});
                trianglesCounter++;
            }
            else if (mapPixels[y*GRID_WIDTH+x].r == 0 && mapPixels[y*GRID_WIDTH+x].g == 255 && mapPixels[y*GRID_WIDTH+x].b == 0) 
            {
                InitializePlatform(&platforms[platformsCounter], (Vector2){x, y});
                platformsCounter++;
            }
        }
    }
    
    free(mapPixels);
    
    //DEBUGGING && TESTING variables
    pause = FALSE;
    srand(time(NULL)); 
    
    // Textures loading
    player.texture = LoadTexture("assets/gameplay_screen/cube_main.png");
    triangleTexture = LoadTexture("assets/gameplay_screen/triangle_main.png");
    platformTexture = LoadTexture("assets/gameplay_screen/platform_main.png");
    player.pEmitter.texture = LoadTexture("assets/gameplay_screen/particle_main.png");
    
    bg = LoadTexture("assets/gameplay_screen/bg_main.png");
    
    // Sound loading
    InitAudioDevice();
    PlayMusicStream("assets/gameplay_screen/music/Flash_Funk_MarshmelloRemix.ogg");
    PauseMusicStream();
    SetMusicVolume(0.5f);
    
    // Did player win?
    startGame = FALSE;
    
    /*
    player.texture = LoadTexture("assets/gameplay_screen/debug.png");
    triangleTexture = LoadTexture("assets/gameplay_screen/debug.png");
    platformTexture = LoadTexture("assets/gameplay_screen/debug.png");
    player.pEmitter.texture = LoadTexture("assets/gameplay_screen/particle_main.png");
    */
    
    // Camera initialization
    mainCamera = (Camera2D){Vector2Right(), (Vector2){6.5f, 6.5f}, Vector2Zero(), TRUE};
    
    // Gravity initialization
    gravity = (GravityForce){Vector2Up(), 1.5f};
    
    // Ground position and coordinate
    groundCoordinadeY = GetScreenHeight()/CELL_SIZE-1;
    groundPositionY = GetOnGridPosition((Vector2){0, groundCoordinadeY}).y;
    
    // Player initialization
    InitializePlayer(&player, (Vector2){4, groundCoordinadeY-1}, (Vector2){0, 15}, 0.35f*GAME_SPEED);
    
    /*
    // Triangles initialization
    InitializeTriangle(&triangles[0], (Vector2){40, groundCoordinadeY-1});
    InitializeTriangle(&triangles[1], (Vector2){50, groundCoordinadeY-1});
    InitializeTriangle(&triangles[2], (Vector2){85, groundCoordinadeY-1});
    
    // Platforms initialization
    InitializePlatform(&platforms[0], (Vector2){20, groundCoordinadeY-1});
    InitializePlatform(&platforms[1], (Vector2){21, groundCoordinadeY-1});
    InitializePlatform(&platforms[2], (Vector2){22, groundCoordinadeY-1});
    InitializePlatform(&platforms[3], (Vector2){23, groundCoordinadeY-2});
    InitializePlatform(&platforms[4], (Vector2){24, groundCoordinadeY-2});
    */
}
Example #11
0
int main() {
	WSAStartup(MAKEWORD(2, 2), &wsa);
	s = socket(AF_INET, SOCK_DGRAM, 0);

	server.sin_family = AF_INET;
	server.sin_addr.s_addr = INADDR_ANY;
	server.sin_port = htons(PORT);

	bind(s, (struct sockaddr *)&server, sizeof(server));

	GenerateMap();

	while (isRunning) {
		incrementIndex = -1;

		memset(buf, '\0', BUFLEN);
		recv_len = recvfrom(s, buf, BUFLEN, 0, (struct sockaddr *)&tempClient.address, &tempClient.addrLength);

		for (int x = 0; x < clientList.size(); x++) {
			if (tempClient.address.sin_port == clientList[x].address.sin_port) incrementIndex = x;
		}

		std::string tempMessage = "";

		switch (ProcessCommand(buf)) {
			case 0 :
				tempClient.uniqueID = incrementID;
				incrementID += 1;

				if (AddConnection(tempClient)) SendMessage("connect", tempClient);

				std::cout << GetConnectionCount() << "/" << maxConnections << std::endl;
				break;
			case 1:
				SendMap(clientList[incrementIndex]);
				break;
			case 2:
				InitializePlayer(clientList[incrementIndex]);

				tempMessage += "advert<position>" + std::to_string((int)clientList[incrementIndex].uniqueID) + ":";
				tempMessage += std::to_string((int)clientList[incrementIndex].player.position.x) + "," + std::to_string((int)clientList[incrementIndex].player.position.y);

				char tempMessageChar[BUFLEN];
				strcpy(tempMessageChar, tempMessage.c_str());
				SendMessage(tempMessageChar, clientList[incrementIndex], clientList);

				break;
			case 3:
				RequestPlayer(clientList[incrementIndex]);
				break;
			case 4:
				UpdatePosition(clientList[incrementIndex], buf);
				break;
		}

		std::cout << buf << std::endl;
	}

	closesocket(s);
	WSACleanup();

	return 0;
}
Example #12
0
void GameServer::Run()
{
	XmlParser parser("settings/Players.xml");
	PlayerType playerType = (PlayerType)parser.ReadInt("/PlayerData/PlayerOneType");
	u32 keybinds[4] = { CL_KEY_LEFT, CL_KEY_RIGHT, CL_KEY_UP, CL_KEY_J };

	Initialize();
	InitializeLevel();
	InitializePlayer(playerType, keybinds);
	InitializeNetwork();

	s32 timeElapsedMs, lastTime, currentTime, waitTime;
	currentTime = lastTime = CL_System::get_time();

	// Main game loop
	while (!m_quit) {
		//Calculate the elapsed time since the beginning of the last frame
		currentTime = CL_System::get_time();
		timeElapsedMs = currentTime - lastTime;
		if (timeElapsedMs > 50)	{
			//Guard to ensure that the frame time isn't too long
			timeElapsedMs = 50;
		}
		lastTime = currentTime;

		m_frameCounter++;

		m_incomingMessages.clear();
		m_outgoingMessages.clear();

		while (true) {
			MessageData packet;
			u32 bytes_read = m_connection.ReceivePacket(packet.data, sizeof(packet.data));
			if (bytes_read == 0) {
				break;
			}
			m_incomingMessages.push_back(packet);
		}

		std::vector<MessageData>::iterator it = m_incomingMessages.begin();
		for (; it != m_incomingMessages.end(); ++it) {
			ProcessMessage((*it).data);
		}

		//Update the game state
		m_level->Update();
		m_updateSignal.invoke(timeElapsedMs);
		m_drawSignal.invoke();

		// Flip the display, showing on the screen what we drew since last call to flip()
		m_window.flip(0);
		
		ComposeUpdateMessage();

		if ((m_frameCounter % 6) == 0) {
			ComposeSyncMessage();
		}
		
		if (m_outgoingMessages.size() > 0) {
			std::vector<MessageData>::iterator it = m_outgoingMessages.begin();
			for (; it != m_outgoingMessages.end(); ++it)
			{
				m_connection.SendPacket((*it).data, (*it).size);
			}
		}		

		//Measure the time for this frame's update
		waitTime = 16 - (CL_System::get_time() - currentTime);
		if (waitTime < 0) {
			waitTime = 0;
		}

		// This call processes user input and other events
		CL_KeepAlive::process(0);

		// Sleep for a little while to avoid using too much of the CPU.
		CL_System::sleep(waitTime);
	}
}
Example #13
0
void UMediaPlayer::PostEditChangeProperty( FPropertyChangedEvent& PropertyChangedEvent )
{
	Super::PostEditChangeProperty(PropertyChangedEvent);

	InitializePlayer();
}