Game/Source/Player.cpp
// Save the player's state
Save the player's state
Save the player ' s state
bool Player::SaveState(pugi::xml_node& playerNode) const
{
	pugi::xml_node player = playerNode.append_child("position");
	player.append_attribute("position_x").set_value(position.x);
	player.append_attribute("position_y").set_value(position.y);
	player = playerNode.append_child("velocity");
	player.append_attribute("velocity_x").set_value(velocity.x);
	player.append_attribute("velocity_y").set_value(velocity.y);
	player = playerNode.append_child("state");
	switch (state)
	{
	case IDLE:
		st = 0;
		break;
	case MOVE:
		st = 1;
		break;
	case JUMP:
		st = 2;
		break;
	case GOD_MODE:
		st = 3;
		break;
	}
	player.append_attribute("player_state").set_value(st);
	player.append_attribute("current_frame").set_value(currentAnimation->GetCurrentFrameID());
	player.append_attribute("horizontal_direction").set_value(horizontalDirection);
	player = playerNode.append_child("lifes");
	player.append_attribute("lifes").set_value(lifes);
	return true;
}
bool Player :: SaveState ( pugi :: xml_node & playerNode ) const { pugi :: xml_node player = playerNode . append_child ( " " ) ; player . append_attribute ( " " ) . set_value ( position . x ) ; player . append_attribute ( " " ) . set_value ( position . y ) ; player = playerNode . append_child ( " " ) ; player . append_attribute ( " " ) . set_value ( velocity . x ) ; player . append_attribute ( " " ) . set_value ( velocity . y ) ; player = playerNode . append_child ( " " ) ; switch ( state ) { case IDLE : st = 0 ; break ; case MOVE : st = 1 ; break ; case JUMP : st = 2 ; break ; case GOD_MODE : st = 3 ; break ; } player . append_attribute ( " " ) . set_value ( st ) ; player . append_attribute ( " " ) . set_value ( currentAnimation -> GetCurrentFrameID ( ) ) ; player . append_attribute ( " " ) . set_value ( horizontalDirection ) ; player = playerNode . append_child ( " " ) ; player . append_attribute ( " " ) . set_value ( lifes ) ; return true ; }
Save the player's state
Save the player ' s state